// Component class
import { Component } from '@angular/core';
@Component({
selector: 'app-hamburgers',
templateUrl: './app.hamburgers.html'
})
export class HamburgersComponent {
showImage: boolean = false;
hamburgers: any[] = [
{
'name': 'Big Kahuna Burger',
'imageSrc': 'http://breds-breakfast.com/bigkahuna.jpg'
}
];
toggleImage():void {
this.showImage = !this.showImage;
}
}
// app.hamburgers.html
<button (click)='toggleImage()'>
<tbody>
<tr *ngFor='let hamburger of hamburgers'>
<td>
<img *ngIf='showImage' [src]='hamburger.imageSrc'>
</td>
</tr>
</tbody>