Skip to content

Instantly share code, notes, and snippets.

View ganqqwerty's full-sized avatar

Yuri Katkov ganqqwerty

View GitHub Profile
@Component({
selector: 'my-product',
template: `
<pre *ngIf="code">
{{(result$|async)|json}}
</pre>
`,
})
export class ProductComponent {
@Input()
@Component({
selector: 'my-app',
template: `<my-product code="7613034626844"></my-product>
<my-product code="7613034626844"></my-product>
<my-product code="7613034626844"></my-product>`,
})
export class AppComponent {
}
<my-product code="7613034626844"></my-product>
<my-product code="7613034626844"></my-product>
<my-product code="7613034626844"></my-product>
resolveProduct(code: string): Observable<any> {
if (this.cache[code]) {
console.log('Returning cached value!')
return this.cache[code];
}
console.log('Do the request again')
this.cache[code] = this.http.get(this.URL+code+'.json').pipe(
shareReplay(1),
catchError(err => {
import { faBalanceScale } from '@fortawesome/pro-solid-svg-icons';
import { faBan } from '@fortawesome/pro-regular-svg-icons';
export class IconsModule {
constructor(library: FaIconLibrary) {
library.addIcons(
faBalanceScale,
faBan,
//... and the rest of icons)
}
/**
* @param {number} a
* @param {number} b
* @return {number}
*/
function sum(a, b) {
return a+b;
}
/** @type {string} */
var a;
/** @type {number} */
const Pi;
/** @type {boolean} */
let isChecked;
@Component({
selector: "app-totoro",
template: `
<pre>{{ totoroDetails | json }}</pre>
`
})
export class TotoroComponent implements OnInit, OnDestroy {
totoroDetails: string;
subscription: Subscription<any>;
constructor(private http: HttpClient) {}
@Component({
selector: 'app-totoro',
template: `<pre>{{totoroDetails$ | async | json}}</pre>`,
})
export class TotoroComponent implements OnInit {
totoroDetails$: string;
constructor(private http: HttpClient) {
}
ngOnInit() {
<div *ngIf="isCompetenceCatalogEditor$ | async"> some content</div>
<div *ngIf="isCompetenceCatalogEditor$ | async"> some more content</div>
<div *ngIf="isCompetenceCatalogEditor$ | async"> some more more content</div>