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>

转载于:https://www.cnblogs.com/liucong7708/p/6472853.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值