将元素追加到QueryList Angular [英] Append element to QueryList Angular
本文介绍了将元素追加到QueryList Angular的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法将新元素追加到QueryList?
Is there a way to append a new element to a QueryList?
例如,我有一个像这样的QueryList:
For example, i have a QueryList like this:
@ContentChildren(SysColumn) syscolumns: QueryList<SysColumn>;
我需要在视图init之后附加另一个SysColumn。 Angular上有可能吗?我尝试追加,但它说这不是QueryList的函数。
And i need to append another SysColumn after the view init. Is it poossible on Angular? I try to append but it says that is not a function of a QueryList.
推荐答案
你可以使用重置
方法
this.syscolumns.reset([...this.syscolumns.toArray(), this.additionalColumn])
Stackblitz Example
这篇关于将元素追加到QueryList Angular的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文