Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
2
Answers
how to add item from array to class using angular2
Dev Maroua
6y
188
1
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
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
How To pass value from 2forms on angular2
how to compare values using angular...