*ngFor

  1. # app.component.ts
  2. import { Component } from '@angular/core';
  3. @Component({
  4. //根主键
  5. selector: 'app-root',
  6. templateUrl: './app.component.html',
  7. styleUrls: ['./app.component.css']
  8. })
  9. export class AppComponent {
  10. title = 'my-app';
  11. list:Array<number> = [1,2,3];
  12. }
  1. # app.component.html
  2. <div *ngFor="let item of list">
  3. {{item}}
  4. </div>