具有动态值和条件的ng-class不在同一个div上工作

时间:2016-07-08 04:56:04

标签: angularjs

这不能正常工作<div id = "number_1" class="number" ng-click="selected='1'" ng-class="{active: selected=='1',firstactive: firstnumber=='1'}"><div class="number-text">1</div></div>但是如果我将ng-class应用于子div它可以正常工作。

1 个答案:

答案 0 :(得分:0)

适合我。你能看看吗

UIImageView
var demo = angular.module('demo', []);
demo.controller('DemoCtrl', function($scope) {
  $scope.firstnumber = 1;
});
.active {
  color: green;
}
.firstactive {
  border: 1px solid red;
}