I have a Laravel 5.1 AngularJS app I am developing. I have a select that I populate with ng-options.
It returns a collection from Laravel that makes up the select options. What I want to do is reuse this ng-options collection in subsequent selects AND remove the previously selected option from the next select.
So for example;
What are your 3 favourite features?
Feature select 1
A
B (assume user selects)
C
Feature select 2
A
C
etc.
In my HTML I have;
<select class="form-control" ng-model="newReport.features1" ng-change="setSelected()" ng-options="feature.feature_name as feature.feature_name for feature in features | filter:{selected:false}" required>
I am hoping I can use ng-change and a setSelected() directive to change the 'selected' value of the selected option to 'true'. With the use of the filter, it would then be removed from the next select.
My challenge - how do I write that directive. I need to change the ng-option not the ng-model.
Any ideas? Thanks!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire