15

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.

Hely Saul Oberto
  • 577
  • 1
  • 10
  • 22

1 Answers1

30

You can use reset method

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

Stackblitz Example

yurzui
  • 205,937
  • 32
  • 433
  • 399