How can I use NgFor without creating arrays to generate matrix UI pattern

后端 未结 5 1368
无人及你
无人及你 2021-01-12 16:36

I would like to implement UI matrix pattern, which should generate dynamically. By receiving input parameter it should decide what would be UI matrix pattern dimensions: For

5条回答
  •  逝去的感伤
    2021-01-12 17:12

    Building arrays just to iterate over them seems lavish. Creating a Directive to replace ngFor is sort of redundant.

    Instead you could use a Pipe returning an Iterable and use it like this:

    {{ i }}

    For an implementation of such a Pipe have a look at my other answer on Repeat HTML element multiple times using ngFor based on a number.

提交回复
热议问题