JavaLearner1
JavaLearner1

Reputation: 627

AngularJS Cookies - Cookies saved in Browser but not displaying

I have injected the cookies and i am saving the value in cookies like this,

$cookies.name = "Alfred";
console.log("cookie " +$cookies.name);

and in HTML i display

{{name}}

the cookies are getting saved and displayed in console, But in HTML it is not getting displayed. I have checked the chrome browser too, the cookies are saved in localhost..

Upvotes: 0

Views: 62

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222700

you need to have a scope variable to display it

$cookies.name = "Alfred";
$scope.cookiname = $cookies.name ;

In HTML

<div>Name: {{cookiname}}</div>

Here is the working App

Upvotes: 1

Related Questions