So, im quite new with angular 2, so far so good. The problem that im having (may be because so use to angular 1) is that i need the class user to be global and use it between diferent components.
in my case i got a User class and im login the user in one component.
@Component({
selector: 'login',
templateUrl: 'app/login/login.html',
providers: [User]
})
export class loginComponent {
submitted = false;
username : string;
password : string;
constructor(public user : User){}
onSubmit(event) { //form event
event.preventDefault();
this.user.login(this.username,this.password, () =>{this.router.navigateByUrl('dashboard')}
So the method login in user is setting the internal variables of user, like name, last name, etc.
in the router i have a diferent component asigned to the route dashboard.
so when i import User i got a new instance of the class. how can i mantain the data in the class?