Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
how to add item from array to class using angular2
Dev Maroua
Jan 24 2018 11:05 AM
154
Reply
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
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
How To pass value from 2forms on angular2
how to compare values using angular...