In Angular
ngFor is directive which accomplishes the motive of displaying repeated or list of contents with least lines of code, this serves the same purpose as
for loops in conventional programming languages.
We can print repeated lines of content based on a number using the javascript/typescript function
Array() which will generate a list of number from 0 to n-1. We traverse this list to produce n repeated lines of content.
Example 1:
Demo.Component.ts
Demo.Component.html
Output:
👁 Image
Example 2:
Inserting template in typescript file and repeating the same element 6 times.
Demo2.component.ts
Output:
👁 Image