-
Notifications
You must be signed in to change notification settings - Fork 80
Select values instead of name #155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
What do you mean store value instead of name? Could you please provide a code snippet to show how you use this |
from your example, the select stores the option names.
This means that if i change the name, the value becomes lost. |
http://nya.io/nya-bootstrap-select/#!/examples/groups-and-more Use |
@lordfriend, I'm not sure if @andrewfam has the same issue as I have but it might be related. So in my case if I use |
@ghiscoding If you need entire object being selected as model value. I shouldn't use |
Thanks @lordfriend but the reason that I use |
@lordfriend thanks a lot for the help but I really need a reference to the full object. How can I have the entire object, while still having the selected value by it's Basically, what comes from my backend server is a For example, here's the collection of options var users = [
{ id: 1, firstname: John, lastname: Doe }
{ id: 2, firstname: Jane, lastname: Doe }
]; Then let say the backend server tells me the If I use this code, then the value get selected but I don't know what is the object unless I do an array search on the users collection. selected object: {{ user }} <!-- how to get selected user object??? -->
<ol class="nya-bs-select" ng-model="userId">
<li nya-bs-option="option in users" data-value="option.id">
<a>
<span>{{option.firstname + ' ' + option.lastname}}</span>
</a>
</li>
</ol> But if I do this code, then I have the reference to the object but the value doesn't get selected selected object: {{ user }}
<ol class="nya-bs-select" ng-model="user">
<li nya-bs-option="option in users">
<a>
<span>{{option.firstname + ' ' + option.lastname}}</span>
</a>
</li>
</ol> I know that I can add an It would be very nice to have another attribute holding the object reference. |
Please bind ngModel to userId and use The reason why you shoud always give a clear element to bind is ngModel is a two-way binding. you must provide a value which can be select from option in order to let directive can select that value base on your model or update your model base on your selection. The issue your faced is really not a case of what this directive care. use ng-change is enough to solve |
I realised that this stores the data as the labels in the options and not the values. Anyway to fix this?
The text was updated successfully, but these errors were encountered: