Skip to content

Instantly share code, notes, and snippets.

@DmitryEfimenko
Last active July 1, 2022 09:37

Revisions

  1. DmitryEfimenko revised this gist Jul 1, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion remote-data-001.ts
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ class MyComponent {
    this.loadProducts();
    }

    private loadProducts() {
    loadProducts() {
    this.http.get('/api/products').subscribe((products) => {
    this.products = products;
    })
  2. DmitryEfimenko created this gist Jul 1, 2022.
    23 changes: 23 additions & 0 deletions remote-data-001.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    @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();
    }

    private loadProducts() {
    this.http.get('/api/products').subscribe((products) => {
    this.products = products;
    })
    }
    }