I try to implement now a local Storage in Angular2 for the first time and get a bit confused.
So, I have First Component, where I register my user
export class FormComponent {
modus = ['first', 'second'];
model: User = new User('', '', '');
constructor(private _cookieService: CookieService) {}
}
Here is class, that I use in FormComponent
export class User {
constructor (
public email: string,
public name: string,
public modus: string
) {}
}
I bind it and everything in form works very good.
Now I want to store it in local storage (3 parameters of User)
But how could I do this?
I leave this page with registration of user and go to other pages, like
export class Part1Component {
public email;
public name;
public modus;
constructor(private _location: Location) {}
myTestFunction(){
/* assign values here
this.email = ;
this.name = ;
this.modus = ;
*/
}
}
How could I get values from storage and assign them here?