VOOZH about

URL: https://www.geeksforgeeks.org/angular-js/how-to-repeat-html-element-multiple-times-using-ngfor-based-on-a-number/

⇱ How to repeat HTML element multiple times using ngFor based on a number? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to repeat HTML element multiple times using ngFor based on a number?

Last Updated : 24 Jun, 2020
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
Comment
Article Tags:

Explore