Last active
July 1, 2022 09:37
-
-
Save DmitryEfimenko/e1067e33e5b3b66f9a68fc525a2fa7f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component({ | |
| selector: 'app-products', | |
| template: ` | |
| <button (click)="loadProducts()">Load Products</button> | |
| <ng-container *ngFor="let product of products"> | |
| <app-product [product]="product"></app-product> | |
| </ng-container> | |
| ` | |
| }) | |
| class MyComponent { | |
| products: Product[]; | |
| ngOnInit() { | |
| this.loadProducts(); | |
| } | |
| loadProducts() { | |
| this.http.get('/api/products').subscribe((products) => { | |
| this.products = products; | |
| }) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment