I am using a mat-table to list the content of the users chosen languages. They can also add new languages using dialog panel. After they added a language and returned back.
You can easily update the data of the table using "concat":
for example:
language.component.ts
teachDS: any[] = [];
language.component.html
And, when you update the data (language.component.ts):
addItem() {
// newItem is the object added to the list using a form or other way
this.teachDS = this.teachDS.concat([newItem]);
}
When you're using "concat" angular detect the changes of the object (this.teachDS) and you don't need to use another thing.
PD: It's work for me in angular 6 and 7, I didn't try another version.
- 热议问题