jeudi 19 janvier 2017

Binding/Modeling to specific character in string in AngularJS

I have data in my controller that looks like this: $scope.myString = "00011" Is there a way I can model checkboxes to each character in the string, something like below?

<input type="checkbox" ng-model="myString.charAt(0)" ng-checked="'1'"> <input type="checkbox" ng-model="myString.charAt(1)" ng-checked="'1'"> <input type="checkbox" ng-model="myString.charAt(2)" ng-checked="'1'"> <input type="checkbox" ng-model="myString.charAt(3)" ng-checked="'1'">

End result, I'd like myString to hold a string of the 1's and 0's I've checked. My above example does not work but shows I have made an attempt to solve the problem.

Aucun commentaire:

Enregistrer un commentaire