My model has a property that is an array, something like this:
{
name: string;
posts: []
}
So I bind the posts property to my component:
<app-my [posts]="person.posts"></app-my>
or
<app-my [(posts)]="person.posts"></app-my>
Inside MyComponent.ts I add or remove elements from this array:
export class MyComponent implements OnInit {
@Input() posts: any;
...
addNew(newPost) { //this work
this.posts.push(newPost);
}
remove(post) { //this does not
this.posts = this.posts.filter(x => x.id != post.id);
}
The view is correctly rendered, but the original person.posts does not change.
That I'm missing?