app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
persons: any = [
{ age: 18, name: 'pepe' },
{ age: 17, name: 'pablo' },
{ age: 13, name: 'hugo' },
{ age: 44, name: 'paco' },
{ age: 15, name: 'luis' }
];
}
app.component.html
<ul>
<ng-container *ngFor="let person of persons">
<li *ngIf="person.age >= 18">{{person.name}}</li>
</ng-container>
</ul>
¿Quieres ver más aportes, preguntas y respuestas de la comunidad?