javascript - Why won't my view get updated in Angular Js? -
i'm trying error handling web app ; more specifically, want display error message whenever server fails deliver message client.
i have controller called controller(using callback function after getting http response) on event(error) , aforementioned controller supposed set ng-hide attribute of div containing error messages false seems view isn't getting updated new value. so, div , message never displayed. i've tried can't seem figure out problem. thank you!
here code error handling controller
var errorctrl=function($scope,$timeout){ $scope.errordivhide = true; $scope.$on("error", function(event, error){ var statustxt = error.statustext; notifiyclientoferror = function(){ $timeout(function(){ $scope.errordivhide = false; console(string(errordivhide));// prints false, should div wont appear $scope.message = "error :"+string(statustxt); }); } notifyclientoferror();
here html
<div ng-controller ="errorctrl"> <div id ="errordiv" ng-hide = "errordivhide"/> {{message}} </div> <p> {{errordivhide}} </p> ( wanted see value; happened true after updated in controller) </div>
Comments
Post a Comment