alternative use of ng-model

273 views
Skip to first unread message

Leonard Modoran

unread,
Jan 6, 2015, 8:20:34 AM1/6/15
to ang...@googlegroups.com
<div data-ng-repeat="practice in practiceList">
<select data-ng-model="myPractice"
data-ng-options="practice.combinedAreaRank for practice in practiceareasApi"
data-ng-click="clearField()"
data-ng-disabled="!myOffice">
<option value="">Select</option>
</select>
</div>


I have the following code. and I want to have for every repeat, the name in ng-model to change, so I whenever I will generate a new select drop-down, I could check for some value in the previous one.
what I want if to generate 3 drop-down, and all of 3 will be connected to the same json, but when I select some value in the first one, the value to be deleted in the second one, and so forth.
Could I do this?
I could hard-code everything but I want to do it inside a of ng-repeat if it's possible
From what I've seen on the internet, you could generate your own directive, or some other solution, but they are not good. I want also to be kind of a best practice, and not a hack.

Thank you!

Sander Elias

unread,
Jan 8, 2015, 7:22:24 AM1/8/15
to ang...@googlegroups.com
Hi Leonard.

You should create a custom filter that returns the array, minus the one's selected in the other selects.
somthing like:

<div data-ng-repeat="practice in practiceList| customNotInFilter:[myPractice2,myPractice3]">


Does that help you enough?

Regards
Sander
Reply all
Reply to author
Forward
0 new messages