javascript - change in a variable outside angular scope -
beginner in angular + looked @ of complex $watch, $digest , $apply threads around still can't make work.
var masterarray = [obj1, obj2, ... ];
this variable not inside angular scope , on plain js , gets updated plain js again outside angular's scope periodically user's interactions.
how can capture change in masterarray
, , update associated $scope
well.
app.('mycontroller', ['$scope', function($scope){ $scope.items = masterarray; }]);
is there way update $scope.items
masterarray changes? thing works when reload page masterarray
pushed localstorage everytime it's updated.
similar concern - data variable (outside angular) arrives little late callback function server in plain js or jquery angular scopes , variables defined during document load.
i couldn't find way update angular scopes associated variables during page load null or empty updated data.
some hack should work:
app.('mycontroller', function($scope){ $scope.items = masterarray; $scope.$watch(function() { return masterarray; }, function(masterarray) { $scope.items = masterarray; }); });
Comments
Post a Comment