Skip to content

Instantly share code, notes, and snippets.

@ganqqwerty
Last active October 8, 2019 18:00
Show Gist options
  • Save ganqqwerty/2358f76542bd4ba7d3c7f0735f524e39 to your computer and use it in GitHub Desktop.
Save ganqqwerty/2358f76542bd4ba7d3c7f0735f524e39 to your computer and use it in GitHub Desktop.
@Component({
selector: 'my-product',
template: `
<pre *ngIf="code">
{{(result$|async)|json}}
</pre>
`,
})
export class ProductComponent {
@Input()
code: string;
result$: Observable<any>;
constructor(private productService: ProductService) {
this.result$ = productService.resolveProduct(this.code);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment