I hereby claim:
- I am yannickglt on github.
- I am yannickglt (https://keybase.io/yannickglt) on keybase.
- I have a public key ASB8a75JKXkABO72ZSTU-no1rhw9XHcfvajybQJK4nye8wo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
// Avoid useless computations and combine the property and its initialization method | |
// Live demo at stackblitz.com/edit/angular-lazy-getter | |
import { Component, ChangeDetectionStrategy } from '@angular/core'; | |
import { LazyGetter } from 'lazy-get-decorator'; | |
@Component({ | |
selector: 'lazy-getter-usage', | |
template: ` | |
<h1>{{ sayHelloWithLazyGetter }}</h1> | |
<h1>{{ sayHelloWithoutLazyGetter() }}</h1> |
// A safe way to call methods in templates | |
// Live demo @ https://stackblitz.com/edit/angular-generic-map-pipe | |
import { Pipe, PipeTransform } from "@angular/core"; | |
// Methods passed to the map pipe cannot (and should not) use the `this` keyword from components. Otherwise, it would not be a pure pipe. | |
@Pipe({ name: "map" }) | |
export class MapPipe implements PipeTransform { | |
public transform<T, R>( | |
thisArg: T, | |
project: (t: T, ...others: any[]) => R, |
// With "+" operator | |
1 + undefined | |
// NaN | |
undefined + undefined | |
// NaN | |
"1" + "2" | |
// "12" |