简体   繁体   中英

Append element to QueryList Angular

Is there a way to append a new element to a QueryList?

For example, i have a QueryList like this:

@ContentChildren(SysColumn) syscolumns: QueryList<SysColumn>;

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.

You can use reset method

this.syscolumns.reset([...this.syscolumns.toArray(), this.additionalColumn])

Stackblitz Example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM