0

Below is my controller which I need to save $stateParams data in the $cookieStore or $cookie. Because when I refresh all the data in $stateParams is gone.

Below is how I did it. But it is not saving data. When I put a console.log all are becoming null.

        var userId = $stateParams.userId;
        $cookies.userName = userId;

        $cookieStore.put('userId', userId);
        $cookieStore.put('appId', $stateParams.appId);
        $cookieStore.put('tempUrl', $stateParams.tempUrl);
        $cookieStore.put('tempName', $stateParams.tempName);
        $cookieStore.put('tempCategory', $stateParams.tempCategory);

        $scope.userId = $cookies.userName;
        $scope.appId = $cookieStore.get('appId');
        $scope.tempUrl = $cookieStore.get('tempUrl');
        $scope.tempName = $cookieStore.get('tempName');
        $scope.tempCategory = $cookieStore.get('tempCategory');

        console.log($scope.userId);
        console.log($scope.appId);
        console.log($scope.tempUrl);
        console.log($scope.tempName);
        console.log($scope.tempCategory);

When I visit the page for the first time data is there. But when I refresh the page, all the consoles are becoming null.

Kalpesh Patel
  • 2,772
  • 2
  • 25
  • 52
shamila
  • 1,280
  • 6
  • 20
  • 45

0 Answers0