ng-repeat输出当前值,ng-class的使用

<style>
.home{
color: red;
background-color:lightblue;
}
</style>
<body>
<div class="container" ng-controller="c1">
<span ng-repeat="x in arry">
<label >
<input type="radio" id="{{x.id}}" ng-click="shownum(x.num)" name="list" /> {{x.num}}
</label>
</span>
<!--ng-class使用--> 注意这里的home用在双引号中间还要加上单引号
<h1 ng-class="'home'">
hello world
</h1>
<!--ng-class转换-->
yes真假切换,控制ng-class选择
<h3 ng-class="{home:yes}" ng-click="yes=!yes">
HELLO,ANGULARJS
</h3>
<hr/>

</div>

<script>
var app = angular.module('app1', []);
app.controller('c1', function ($scope) {
$scope.arry=[
{
'id':'liu',
num:965

},{
'id':'luke',
num:562
},{
'id':'jack',
num:326
}
]
//点击当前项,输出当前项的值
$scope.shownum=function(x){
console.log(x);

}


})

</script>
posted @ 2017-02-27 11:18  liucong2016  阅读(1510)  评论(0编辑  收藏  举报