bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

bug(typeahead) inside modal

Open axlekb opened this issue 13 years ago • 5 comments

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:

  1. Why isn't the typeahead ng-model value in the modal getting returned to the ModalDemoCtrl from the ModalInstanceCtrl?
  2. In the previous version, the value shown in the typeahead input after selection would have been the label, not the select (i.e. "Joe" instead of 1)

Here's the Plunkr

axlekb avatar Sep 09 '13 17:09 axlekb

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"'.

AGiorgetti avatar Sep 10 '13 07:09 AGiorgetti

Have a look at #969 and the mods I made to the Modal module, they solved all these kinds of problems for me.

AGiorgetti avatar Sep 10 '13 10:09 AGiorgetti

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.).

pkozlowski-opensource avatar Sep 10 '13 11:09 pkozlowski-opensource

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.

axlekb avatar Sep 10 '13 12:09 axlekb

This can stay closed, and I'll follow 981 which someone else opened.

axlekb avatar Sep 10 '13 20:09 axlekb