首页 > Web开发 > 详细

angJs使选中的li背景颜色不同

时间:2016-05-13 12:48:29      阅读:201      评论:0      收藏:0      [点我收藏+]

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>test</title>
<script type="text/javascript" src="../js/angular-1.2.22.js" ></script>
<script>
var myApp = angular.module("myApp", []);
myApp.controller("testCtrl", function($scope){
$scope.data = [0,1,2,3,4];
$scope.isCurrent = function(index){
$scope.bg = [];
$scope.bg[index] = ‘current‘;
}
});
</script>
<style>
ul { margin:100px auto; width:1120px; list-style:none}
ul li { display:block; width:200px; height:200px; background:#efefef; border:solid 1px #000; float:left; margin:10px; cursor:pointer}
.current { background:#f00}
</style>
</head>

<body ng-app="myApp">
<ul ng-controller="testCtrl">
<li ng-repeat="item in data" ng-class="bg[$index]" ng-click="isCurrent($index)"></li>
</ul>
</body>
</html>

angJs使选中的li背景颜色不同

原文:http://www.cnblogs.com/zml-java/p/5487153.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!