javascript - Angular multiselect menu with arbitrary bindings -
how can bind select menu bunch of arbitrary options in select menu.
i tied this:
<select multiple class="form-control"> <option ng-model="some.prop">average</option> <option ng-model="foo.bar.baz">minimum</option> <option ng-model="another">maximum</option> </select> but doesn't work, using ng-selected works, 1 way (i.e. doesn't change variable when selecting/unselecting option.
<select multiple class="form-control"> <option ng-selected="some.prop">average</option> <option ng-selected="foo.bar.baz">minimum</option> <option ng-selected="another">maximum</option> </select>
when selecting/deselecting <option> items in <select>, ng-model attached <select> change. using ng-selected <option> elements doesn't change that: property specified ng-selected read-only.
here's example: http://plnkr.co/edit/zilmbj77wqolxnti6b10?p=preview
perhaps can represent scenario better using group of check-boxes? this:
<input type="checkbox" ng-model="some.prop" ng-true-value="a" ng-false-value="b" /> <input type="checkbox" ng-model="foo.bar.baz" ng-true-value="foo" ng-false-value="bar" /> <input type="checkbox" ng-model="another" ng-true-value="0" ng-false-value="1" /> to accomplish bi-directionally bound list of choices, use custom drop-down multiple checkboxes, one: http://isteven.github.io/angular-multi-select/#/main
Comments
Post a Comment