[英]Angular ng-class not working
I've got the following HTML, and I'm trying to print a class using ng-class
to the box, but it doesn't seem to work. 我有以下HTML,并且我尝试在框内使用ng-class
打印一个类,但是它似乎不起作用。 What am I doing wrong? 我究竟做错了什么?
http://plnkr.co/edit/5KqnetMmq5DPe1Dm2ecc?p=preview http://plnkr.co/edit/5KqnetMmq5DPe1Dm2ecc?p=preview
<div ng-controller="myObject">
<a href="javascript:void(0)" ng-click="updateClass()">{{ type ? 'One' : 'Two' }}</a>
<div class="box" ng-class="{{ type ? 'one' : 'two' }}"></div>
</div>
ng-class gets evaluated on it's own. ng-class会自行评估。 You don't need the {{}} 您不需要{{}}
<div class="box" ng-class=" type ? 'one' : 'two' "></div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.