angucomplete-alt icon indicating copy to clipboard operation
angucomplete-alt copied to clipboard

Small fix necessary if you set initital-value to be your ng-model but…

Open antony opened this issue 10 years ago • 4 comments

… also update your ng-model as a result of making a selection. Essentially we must unbind the initial-value function in two scenarios - either if an initial-value is set, or if an item is selected.

Apologies for this one - spotted it as I was rolling out the new version across my site.

antony avatar Jun 13 '15 14:06 antony

Why is this necessary?

ghiden avatar Jun 14 '15 17:06 ghiden

Because if you take the initial-value as an object, the callOrAssign function is called as a result, which in turn updates your model (which is assigned as initial-value), which causes the display value to become the external model value.

It's hard to explain - but this is what I saw happening in my application, and adding this fix stopped the behaviour. I'll write a test for this asap, but I first wanted to ensure that other people didn't run into this.

antony avatar Jun 15 '15 09:06 antony

When I tested it works as expected. And, unbind function should have no effect once it's called. So I don't see why we need this in callOrAssign. If you can create an example, that would be great.

ghiden avatar Jun 15 '15 09:06 ghiden

How do assign the selected value to my ng-model, looking at html code, ng-model is set to searchStr, i want to change it to my own object to save in the database. Thank you

bakulaw avatar Jan 13 '17 01:01 bakulaw