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:

  1. the $watch function not update $scope.currentuser hoping to. gets updated when refresh whole web page.
  2. 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

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -