AngularJS flag filter not working

In my jsfiddle, I cannot pass the AngularJS binding value as a parameter to the checkbox.

In this code, I:

<input type="checkbox" ng-click="includeColour('Red')" /> Red<br/>
<input type="checkbox" ng-click="includeColour('Orange')" /> Orange<br/>
<input type="checkbox" ng-click="includeColour('Yellow')" /> Yellow<br/>

I just changed some of them as shown below:

<div ng-repeat="f in fruit">
    <input type="checkbox" ng-click="includeColour('{{f.colour}}')" />{{f.colour}}  <br />
</div>

But it does not work.

+4
source share
1 answer

You do not need to put the {{}}scope in passing the variable, just change

FROM

 <input type="checkbox" ng-click="includeColour('{{f.colour}}')" />{{f.colour}}  <br />

For

 <input type="checkbox" ng-click="includeColour(f.colour)" />{{f.colour}}  <br />

Job JsFiddle

+4
source

Source: https://habr.com/ru/post/1621866/


All Articles