use
ng-class="{'level-{{row.level}}': true, active: TestFlag==true}"
سؤال
I am assigning ng-class
to an element using this.
ng-class="{'level-' + {{row.level}}:true,active:TestFlag==true}"
but it is giving me tons of errors. What is wrong with its syntax? What is the correct way of doing this?
المحلول
use
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>