Skip to content

Instantly share code, notes, and snippets.

@CarterTsai
Created November 23, 2013 12:11
Show Gist options
  • Save CarterTsai/7613937 to your computer and use it in GitHub Desktop.
Save CarterTsai/7613937 to your computer and use it in GitHub Desktop.
A Pen by CarterTsai.
<div ng-app="" ng-controller="MainCtrl as main">
<ul>
<li ng-repeat="item in items">
<a href="#" ng-class="{myColor: main.colorful == $index}"
ng-click = "main.colorful = $index"
ng-bind = "item.name">
</a>
</li>
</ul>
</div>
function MainCtrl($scope) {
$scope.items = [
{id:"0", name: "Javascript" },
{id:"1", name: "C/C++" },
{id:"2", name: "AngularJS" },
]
$scope.colorful = 0;
}
.myColor {
background-color : #ccc;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment