javascript - AngularJs - $digest() iterations reached with $cookieStore -
app.controller('appctrl', function ($scope, $cookiestore) { $scope.$watch(function(){return $cookiestore.get('currentuser');}, function(newvalue, oldvalue){ if(newvalue !== oldvalue){ $scope.currentuser = $cookiestore.get('currentuser'); } }); });
i have developed code above intention watch value saved in $cookiestore. when user singed in successfully, json object saved in $cookiestore, of $watch function, user information display on top corner of page.
$cookiestore.put('currentuser', response);
i having 2 issues solution:
- the $watch function not update $scope.currentuser hoping to. gets updated when refresh whole web page.
- somewhere in solution, $digest() functions called repeatedly. tried resolve problem adding if(newvalue !== oldvalue){}, not work.
if change solutions use $cookies instead of $cookiestore, seems working expected, $cookies not allow me save json object, why prefer use $cookiestore instead.
any ideas? appreciated it!
Comments
Post a Comment