Search code examples
javascriptangularjsng-class

ng-class allows assignment operator. is it a bug or feature?


I recently noticed that ng-class allows assignment operator is it a bug or a feature.

<li ng-repeat="cat in cats" ng-class="{active: cat = 'some-text'}">{{cat}}</li>

correct usage

<li ng-repeat="cat in cats" ng-class="{active: cat == 'some-text'}">{{cat}}</li>

also look at the plunk behaviour

Allowing assignment operator is a bug or a feature?


Solution

  • Raised an issue in GitHub and got a clarification

    issue : https://github.com/angular/angular.js/issues/16049

    issue-comment: https://github.com/angular/angular.js/issues/16049#issuecomment-308092056