angularjs - Dynamically create angular checkboxes and get their values -
i have program needs check api current users on system, , present form administrator can decide ones give powers. can't figure out how information modeled formdata in order this. have not work:
<p ng-repeat="f in mdfields"><input type="checkbox" ng-model="formdata.checkboxes" ng-true-value="{{f}}"> {{f}}</p> the mdfields array of every user's name.
that may give idea though of want: want display names of users, , let admin select many of them wants, have information available $scope.formdata can pass api call , stuff.
edit: clarify bit, list of checkboxes gets called can change often, , ideally, want ability send data server says like: ["jao smith":true] ["frank jones":false]
although fine send server names of people have been checked.
without knowing more models there several ways can it:
as property of fobject - can filter mdfields array find selected:
<input ng-model="f.selected"> all in 1 scope variable array (not choice if doing filtering because indexing changes):
<input ng-model="formdata.checkboxes[$index]" ng-init="formdata.checkboxes[$index]=formdata.checkboxes[$index]|false"> in scope variable object - easy collect selected id
<input ng-model="formdata.checkboxes[f.id]">
Comments
Post a Comment