Boostrap list

by Bretto

HTML

<div ng-app="">
  <div ng-controller="Ctrl">
    <ul class="nav nav-list" ng-repeat="color in colors">
      <li ng-click="setSelectedIndex($index)" ng-class="{active: selectedIndex == $index}">
          <a href="#">{{color}} {{$index}}</a>
      </li>
    </ul>
    <tt>selectedIndex = {{selectedIndex}}</tt>
   </div>
</div>

CSS

</style> <!-- Ugly Hack due to jsFiddle issue: http://goo.gl/BUfGZ -->
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<script src="http://docs.angularjs.org/angular-1.0.0rc8.min.js"></script>
<style>
.ng-invalid { border: 1px solid red; }

JavaScript

function Ctrl($scope) {

    $scope.colors = ['blue', 'green', 'red'];
    $scope.selectedIndex = undefined;

    $scope.setSelectedIndex = function($index) {
        $scope.selectedIndex = $index;
        this.selected = 'active';
        console.log($index);
    }
}