我正在ng-class
使用它分配给一个元素。
ng-class="{'level-' + {{row.level}}:true,active:TestFlag==true}"
但它给了我很多错误。它的语法有什么问题?这样做的正确方法是什么?
利用
ng-class="{'level-{{row.level}}': true, active: TestFlag==true}"
I think you'll need to pull the first part off and do it like this:
ng-class="{active:TestFlag}" class="{{'level-' + row.level}}"
Demo: http://plnkr.co/edit/NSZbm1sntT3uwDgx4g0L?p=preview
You can also build an object in your controller:
$scope.classSet = {};
$scope.classSet['level-' + $scope.row.level] = true;
$scope.classSet['active'] = $scope.TestFlag;
<p ng-class="classSet">Here</p>