javascript - conditional ngClass doesn't work in my case -
<li ng-class="{selected: 'checked==true'}" ng-repeat="item in data"> <span>item.name</span> <input ng-model="checked"/> </li>
i want add together class 'selected' if checkbox checked. above code added selected class before click on checkbox, what's wrong?
well, in question, have mentioned input checkbox. if miss type input, treats text input.
so, input should this.
<input type="checkbox" ng-model="checked"/> now, if utilize ng-model checkbox, corrosponding variable checked here, can hold true or false, both boolean. so, dont need compare them in ng-class.
only <li ng-class="{selected: checked}" ng-repeat="item in data"> suffice.
here plunker created you.
javascript angularjs
No comments:
Post a Comment