Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am new to Angular and have basic problems, getting Angular-UI-Bootstrap to work in combination with AngularJS. Here a simple example, an usual input field that uses ng-change for event handling, and which has a popover. Without the popover attributes, the codes works fine. When the popover attributes are added, the popover is displayed correctly, and looks fine, but the event handler is not called, and also the password model not updated, when the value of the input field changes.

Same problem holds e.g. if I have a button with event handling code and a popover. Same problem also if I do not use popover, but tooltip.

<input type="password" ng-model="password" placeholder="New Password"
ng-change="onPasswordChanged()" popover="I am a popover!" 
popover-trigger="mouseenter" />

I am using ui-bootstrap-tpls-0.3.0.js and AngularJS v1.0.7.

Does someone know what the problem is?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Popover directive creates a child scope, so when you bind your model to a primitive, the binding will stay inside that scope (it will not propagate upwards). See "What are the nuances of scope prototypal / prototypical inheritance in AngularJS?" for more info on inheritance.

Workaround is to use a dot notation when referencing your models:

<input type="password" ng-model="data.password" popover="I am a popover!" 
popover-trigger="mouseenter" />

DEMO PLUNKER

share|improve this answer
    
Thanks, works for me! From a newbie perspective, this looks to me like an odd and unintuitive restriction though. –  OliverM Jun 24 '13 at 10:04
1  
I know what you're saying. Just try to always reference your models through dot notation and you'll save yourself from lot of headache. –  Stewie Jun 24 '13 at 10:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.