AngularJS - remove select option from options collection on select...

28 views
Skip to first unread message

regdunlop0

unread,
Nov 4, 2015, 10:27:10 AM11/4/15
to AngularJS
I have 3 selects that use the same options json collection I pull from storage.  I am trying to remove/disable option items from the subsequent selects once they have been selected.

Example:

Select 1
Options(fruit collection)
 Apple X
 Orange
 Banana

Select 2 (fruit collection - with Apple removed/disable due to selected)
 Orange
 Banana

How can I do this.  Seems a pretty regular need.

Thanks!

Ginie Kim

unread,
Nov 4, 2015, 10:44:41 AM11/4/15
to ang...@googlegroups.com
Hello~

I cannot tell you in detail.

But you can use two way.

One is scope.$watch, another is ng-change built-in directive.

You maybe have to consider with $index.

Good luck to you!

2015년 11월 5일 목요일, regdunlop0<gke...@tenzing-im.com>님이 작성한 메시지:
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

regdunlop0

unread,
Nov 4, 2015, 11:37:49 AM11/4/15
to AngularJS
Thanks Ginie,

I see I can add ng-change to trigger a directive.  

<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>

My question is - how do I write the directive to set selected on the ng-option (not the ng-model) to true?

Thanks.


On Wednesday, 4 November 2015 10:44:41 UTC-5, Ginie Kim wrote:
Hello~

I cannot tell you in detail.

But you can use two way.

One is scope.$watch, another is ng-change built-in directive.

You maybe have to consider with $index.

Good luck to you!

2015년 11월 5일 목요일, regdunlop0<gke...@tenzing-im.com>님이 작성한 메시지:
I have 3 selects that use the same options json collection I pull from storage.  I am trying to remove/disable option items from the subsequent selects once they have been selected.

Example:

Select 1
Options(fruit collection)
 Apple X
 Orange
 Banana

Select 2 (fruit collection - with Apple removed/disable due to selected)
 Orange
 Banana

How can I do this.  Seems a pretty regular need.

Thanks!

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages