Save a value of a link in Angular 5 to a cookie

0

One question, I'm new to this and I'm trying to take a value of one in angular 5 and pass it to ts of the component to save it in cookie .

<a href="#" onclick="pulsar()" [routerLink]="['/rutas']" 
ng-value="Madrid" id="name" >

And in the ts

pulsar(){
var name='name';
this.cookieService.set('Rutas', 'name' );
console.log(name);
} 

Finally I'm trying to click on that button to add the Madrid value to a cookie.

Thanks

    
asked by Ivan Castillo 14.03.2018 в 19:06
source

1 answer

0

Try localStorage.

pulsar(){
var name='name';
localStorage.setItem("rutas", name);
console.log(localStorage.rutas);
} 
    
answered by 14.03.2018 в 19:29