Reputation: 3941
I have the following code in one of my controllers.
$scope.artistId = $cookies.artistId;
$scope.artistName = $cookies.artistName;
$scope.switchArtist = function(artist) {
$scope.artistName = '';
$scope.artistId = '';
$scope.artist = artist;
$cookies.artistName = artist.name;
$cookies.artistId = artist.id;
$scope.artistName = artist.name;
$scope.artistId = artist.id;
$rootScope.$broadcast(ARTIST_EVENTS.switchedArtist);
};
Then in my view I have
{{ artistName }}
When I trigger the $scope.switchArtist(); function, that works. However when I refresh the page $scope.artistName loses it's value in my view again.
[edit]
I'm using angularjs 1.3.14
Upvotes: 0
Views: 799
Reputation: 4705
I believe you need to use .get and .put for $cookies instead of regular dot notation. You can see here in the 1.4 version docs - assuming that's what you are using.
Upvotes: 1