javascript - Update cookies with AngularJS -


i'me noob on angularjs. i'm trying manage cookies doesn't works want. i've 2 version of code seams identical if first 1 works... second 1 failed.

the code login form here :

(function() {      var app = angular.module('userapp', ['suivichantiers', 'ngcookies']);        app.controller('userlogin', ['$scope', '$http', '$cookies',          function($scope, $http, $cookies) {              $scope.login = function() {              $scope.user = this.user;                $http.post('services/user.php', {                action: 'login',                user: $scope.user              }).success(function(data) {                if (data.error) {                  // [...]                } else if (data.message == 'success') {                  $cookies.user = data.data;                  console.log("user : " + $cookies.user); // output : user : ms1ovfewwkrzeu5ettbnvfv3tve9pq==                  window.settimeout(function() {                    if ($cookies.redirectto == null) {                      document.location.href = "chantier/index.html";                    } else {                      var dest = $cookies.redirectto;                      $cookies.redirectto = null;                      document.location.href = dest;                    }                  }, 3000);                }              });            };            // [...]          })();      })();
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-cookies.min.js"></script>  <h1>login form ...</h1>

and in "chantier/index.html" controller have :

(function() {  	var app = angular.module('chantierapp', ['ngcookies']);  	  	app.controller('chantierlistcontroller', ['$scope', '$cookies', 'userservice', function($scope, $cookies, userservice) {  		$scope.user = userservice.user;  		console.log("user : "+$cookies.user); // output : user : undefined $cookies.redirectto not empty    	}]);  })();
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js"></script>  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-cookies.min.js"></script>

(sorry long code post) can explain me why cookies not updated?

thanks help.

finaly solved problem ... ok. there very persistent cache on files (even after deleting cache files , tmp files). launched browser in private mode , worked.

thanks help.


Comments