I am running into a strange one way binding behavior within a Angular-UI-Bootstrap Modal.
Inside a modal html, two day data binding seems to work fine but the scope variable model at the controller does not update for some reason.
If, however, the scope variable is an object, then the two way binding seems to propagate to the controller.
Does anyone know why this is happening? Anyway to fix it?
I have made a plunker to demonstrate the problem.
This seems to be the most common problem I see people having with angular; nested scopes. Have a look at the following resource: http://jimhoskins.com/2012/12/14/nested-scopes-in-angularjs.html
This essentially boils down to the following. If you attempt to access
$scope.someVal
, angular will search up the parent chain looking forsomeVal
, and if found will return it to you. If you try and changesomeVal
, it will simply create a newsomeVal
to the current scope.If however you attempt to access
$scope.someObj.someVal
, reading acts the same way. Except this time if you try to changesomeVal
, it will change the value insidesomeObj
, no matter which scope is commanding the update.