Skip to content

Instantly share code, notes, and snippets.

@nimaparsi
Created March 9, 2016 07:22
Show Gist options
  • Save nimaparsi/a6250bcda105a1f18b48 to your computer and use it in GitHub Desktop.
Save nimaparsi/a6250bcda105a1f18b48 to your computer and use it in GitHub Desktop.
// app
var app = angular.module('angularjs-starter', []);
app.controller('MainCtrl', function($scope) {
$scope.message = 'World';
$scope.GiantList = [{name: 'one'}, {name: 'two'}, {name: 'three'}];
$scope.saveData= {};
$scope.setSelected = function(selected) {
$scope.selected = selected;
}
});
// html
<body ng-controller="MainCtrl">
{{ selected }}
<ul>
<li ng-class="{current: selected == 100}">
<a href ng:click="setSelected(100)">ABC</a>
</li>
<li ng-class="{current: selected == 101}">
<a href ng:click="setSelected(101)">DEF</a>
</li>
<li ng-class="{current: selected == $index }"
ng-repeat="x in [4,5,6,7]">
<a href ng:click="setSelected($index)">A{{$index}}</a>
</li>
</ul>
<div
ng:show="selected == 100">
100
</div>
<div
ng:show="selected == 101">
101
</div>
<div ng-repeat="x in [4,5,6,7]"
ng:show="selected == $index">
{{ $index }}
</div>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment