Skip to content

Commit

Permalink
angular 4 test: fixed add/delete item
Browse files Browse the repository at this point in the history
  • Loading branch information
vkamiansky committed Sep 29, 2017
1 parent b6433ee commit 9c91ec6
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ export class ArticleListComponent implements OnInit {
];
}

addArticle(article) {
addArticle(article: Article) {
if(-1 == article.id)
{
article.id = 1 + this.articles.reduce((a, x) => x.id > a ? x.id: a, -1);
}
this.articles.unshift(article);
}

deleteArticle(article){
deleteArticle(article: Article){
let index = this.articles.findIndex((o) => o.id == article.id);
if(index)
if(-1 != index)
{
this.articles.splice(index, 1);
}
Expand Down

0 comments on commit 9c91ec6

Please sign in to comment.