bug(typeahead) inside modal
0.6.0 and 1.2.0.rc2
I had this working with 0.4.0, there were some other issues preventing it from working with 0.5.0, but haven't been able to figure it out on the latest code. Am I missing something?
There are two issues:
- Why isn't the
typeaheadng-modelvalue in the modal getting returned to the ModalDemoCtrl from the ModalInstanceCtrl? - In the previous version, the value shown in the
typeaheadinput after selection would have been thelabel, not theselect(i.e. "Joe" instead of 1)
Here's the Plunkr
The new $modal templates uses transclusion to add the modal content to the dialog. Looking at the transclusion documentation and some stackoverflow answers to related questions you should be able to have your two way binding work using something like: 'ngModel="$parent.yourproperty"'.
Have a look at #969 and the mods I made to the Modal module, they solved all these kinds of problems for me.
Yes, this is essentially the same issue as #969 so let's move the discussion in there. I can see how this can be confusing so we need to improve. For now the best option is to assure that there is "dot" in the ngModel expression: http://plnkr.co/edit/fBbEqEMj4VELzkJH0olw?p=preview
@AGiorgetti using $parent is not really advisable in this case as it might easily break as soon as you insert any scope-creating directive (ngIf, ngSwitch, ngInclude etc.).
Sorry, I'm not sure I got the answer to part 2 of my question: I was under the impression (from ng-ui-b 0.4.0 and ng 1.1.5) that typeahead="u.id as u.name for u in items" would always display the name, but bind the id. After selection, the id is displayed rather than the name.
This can stay closed, and I'll follow 981 which someone else opened.