This file contains 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
@Injectable({ providedIn: 'root' }) | |
export class FeatureFlagGuard implements CanActivate { | |
constructor(private userQuery: UserQuery) { | |
} | |
canActivate(route: ActivatedRouteSnapshot): boolean { | |
return this.userQuery.hasFlags(route.data.flags); | |
} | |
} |
This file contains 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
import { Directive, ElementRef } from '@angular/core'; | |
@Directive({ | |
selector: '[autofocus]' | |
}) | |
export class AutofocusDirective { | |
constructor(private host: ElementRef) {} | |
ngAfterViewInit() { | |
this.host.nativeElement.focus(); |
This file contains 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
{ | |
"todos": { | |
"entities": { } | |
}, | |
"cart": { | |
"entities": { } | |
}, | |
"session": { | |
"firstName": "" | |
} |
This file contains 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
openDialog<T>(dialogContent: Type<T>) { | |
const footer = document.createElement('p'); | |
footer.innerText = 'footer'; | |
const dialogContentRef = createComponent(dialogContent, { | |
environmentInjector: this.injector | |
}) | |
const dialogRef = createComponent(DialogComponent, { | |
environmentInjector: this.injector, |
This file contains 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
interface Profile { | |
firstName: string; | |
lastName: string; | |
address: { | |
street: string; | |
city: string | |
} | |
} | |
const profileForm = new FormGroup<ControlsOf<Profile>>({ |
This file contains 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
class Observable { | |
constructor(functionThatThrowsValues) { | |
this._functionThatThrowsValues = functionThatThrowsValues; | |
} | |
subscribe(next, error, complete) { | |
if (typeof next === "function") { | |
return this._functionThatThrowsValues({ | |
next, |
This file contains 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
export class CopyAction extends Action { | |
getLabel() { | |
return 'Copy'; | |
} | |
invoke() { | |
inject(CopyService).copy(); | |
} | |
} |
This file contains 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
@Injectable() | |
export class OfflineInterceptor { | |
private onlineChanges$ = fromEvent(window, 'online').pipe(mapTo(true)); | |
get isOnline() { | |
return navigator.onLine; | |
} | |
intercept(req, next) { | |
return next.handle(req).pipe( |
This file contains 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
@Directive({ | |
selector: '[range]' | |
}) | |
export class RangeDirective { | |
_range: number[]; | |
@Input() | |
set range( value ) { | |
this.vcr.clear(); | |
this._range = this.generateRange(value[0], value[1]); |
This file contains 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
import { ComponentFactoryResolver, ComponentRef, Directive, EventEmitter, Input, Type, ViewContainerRef } from '@angular/core'; | |
import { Subscription } from 'rxjs'; | |
@Directive({ | |
selector: '[lazyComp]' | |
}) | |
export class LazyCompDirective { | |
private _inputs; | |
private _outputs; | |
private subscription = new Subscription(); |
NewerOlder