javascript - Child controller $scope property changes not updating for parent -
javascript - Child controller $scope property changes not updating for parent -
i'm still new angularjs , scopes, i'm having problem scope values changed in kid controllers not affecting parent value properly.
one example:
i have kid controller watches changes in textarea. when occur, set boolean flag indicate document has unsaved changes.
editor.on('input propertychange', function(){ $scope.unsaved = true; }).focus();
however, never seems filter parent scope. root template has anchor:
<a ng-class="{'active': unsaved}" ...
the class set on load, never changes when $scope.unsaved
does.
if set $scope.$parent.unsaved
, alter template sec time input event fires.
one thing instead of having
editor.on('input propertychange', function(){ $scope.unsaved = true; }).focus();
you add together ng-change
event:
<input type="text" ng-model="a" ng-change="madechange()"/>
and add together new method in scope
:
$scope.madechange = function() { $scope.saved = false; }
plunkr here
javascript angularjs
Comments
Post a Comment