Dev Teywa

Dev Teywa

  • NA
  • 250
  • 37.9k

how to add item from array to class using angular2

Jan 24 2018 11:05 AM
Hello,
I have a user class
 
export class User {
constructor(
public email: string,
public password: string) { this.email=email;this.password=password}
}
 
I'm storing the values of this class in an array like this
 
users :User[]= [
new User('[email protected]','adm9'),
new User('[email protected]','a23')
];
 
after I create an add_user function that allows to add a user

add_user(user:User)
{
this.users.push(the problem is here );
console.log(this.users);
this._router.navigate(['login']);
}
 
ho can i do please ?
thanks in advance 
 
 
 
       

Answers (3)