Skip to content

Instantly share code, notes, and snippets.

@allenyang79
Created August 29, 2013 10:35
Show Gist options
  • Save allenyang79/6376563 to your computer and use it in GitHub Desktop.
Save allenyang79/6376563 to your computer and use it in GitHub Desktop.
.error{
color:#f00;
}
.warning{
color:#0f0;
}
.highlight{
background:#efefef;
}
<html = ng-app="app">
<body ng-controller="MyCtrl">
<div>
<ul>
<li ng-repeat="item in items" ng-class="{highlight: $index % 4 ==0}">
{{$index}}
show:<input type="checkbox" ng-model="item.show"/><br/>
error:<input type="checkbox" ng-model="item.isError"/><br/>
warning:<input type="checkbox" ng-model="item.isWarning"/><br/>
<span ng-class="{error: item.isError, warning: item.isWarning}">{{item.name}}</span><br/>
<img ng-src="{{item.img}}" ng-show="item.show"/>
{{item.isWarning}}
</li>
</ul>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"></script>
</body>
</html>
var app = angular.module('app',[]);
app.controller('MyCtrl', function($scope){
$scope.items=[];
$scope.items.push({
show:true,
name:"bill",
img:'http://www.placehold.it/50x50'
});
$scope.items.push({
show:true,
name:"merry",
img:'http://www.placehold.it/50x50'
});
$scope.items.push({
show:true,
name:"joe",
img:'http://www.placehold.it/50x50'
});
$scope.items.push({
show:true,
name:"brown",
img:'http://www.placehold.it/50x50'
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment