-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(ngModel): bind to single property instead of entire object #107
Conversation
I wrote some tests over in #108 |
+1 to this. This would be great. |
+1, just came here to find the documentation on how to bind to a single property of an object and didn't even realize it wasn't a feature. |
How will this work for data that is loaded (for updating existing data for example)? You won't be able to set the For creating new data, this will be very useful, but for updating existing data, one would still need to pull a trick to get the loaded data in the |
@lowerends can you explain better the situation? Btw, did you check the Plunker? There is a button that will update the model and I'm not sure if that is what you were referring to. |
Well, in that Plunker, say you have selected Adam and saved the email address to the database. If you then load the form for editing, thereby loading |
After looking into it a bit more, it will indeed be possible to set the selected item using the same functionality as the button in the Plunker. BTW, this PR is a great addition. As soon as it's released, I'll test it against dynamically loaded data as well. |
@lowerends From what I understand what you're asking is if the refresh function (and hence $select.search is set) is called on the ui-select choices with the new value set on the ng-model. The answer is no, not currently - forked plunkr http://plnkr.co/edit/Tj3SVw89qWyivjJz5Iyd?p=preview. (I'm updating a variable to hold the last refresh value sent through). @dimirc This only would affect when the option |
Really anxious for this one; I'm writing a lot of workaround code for it now that I know I'll just have to remove later, any idea when it will be merged and available? |
@WhatFreshHellIsThis should be merged this week, I was just waiting some feedback and want to release v0.5 with other fixes too |
Excellent news, thank you @dimirc! |
feat(ngModel): bind to single property instead of entire object
In cases when we don't want the ngModel to be bind to the whole object but just to a property, we could specify it at the repeat attribute.
Something like this:
person.email as person in people
I'm doing some refactoring at this PR but the important part of the code is at the link function uf uiSelect directive, where a parser and formatter is added (to have 2 way binding)
PD: For static data seams to be working fine. I haven't check yet how could this behave for remote data.
Demo plunker
Closes #68