What angularjs expression syntax is this in ng-class

前端 未结 5 1274
渐次进展
渐次进展 2021-01-30 13:04

The AngularJS Noob Handbook has some code which reduces class manipulation to a simple expression and binding :

...&         


        
5条回答
  •  北荒
    北荒 (楼主)
    2021-01-30 13:43

    This is mentioned briefly (too briefly, in my opinion) in the ngClass documentation. If you pass an object to ngClass, then it will apply each key of the object as a class to the element if that key's value is true. For example:

    $scope.first = true
    $scope.second = false
    $scope.third = true
    

    with

    would result in

提交回复
热议问题