Angular + Material - How to refresh a data source (mat-table)

前端 未结 23 1389
自闭症患者
自闭症患者 2020-11-28 01:59

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.

23条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 02:47

    Well, I ran into a similar problem where I added somthing to the data source and it's not reloading.

    The easiest way I found whas simply to reassigning the data

    let dataSource = ['a','b','c']
    dataSource.push('d')
    let cloned = dataSource.slice()
    // OR IN ES6 // let cloned = [...dataSource]
    dataSource = cloned
    

提交回复
热议问题