View relative-guard-3.ts
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 { Injectable } from '@angular/core'; | |
import { ActivatedRouteSnapshot, createUrlTreeFromSnapshot } from '@angular/router'; | |
@Injectable({ providedIn: 'root' }) | |
export class MyGuard implements CanActivate { | |
canActivate(route: ActivatedRouteSnapshot) { | |
if(checkData(route)) { | |
return createUrlTreeFromSnapshot(route, ['../sibling']); | |
} |
View relative-guard-1.ts
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 MyGuard implements CanActivate { | |
constructor(private router: Router, private route: ActivatedRoute) { } | |
canActivate(route: ActivatedRouteSnapshot) { | |
if(checkData(route)) { | |
this.router.navigate(['../sibling'], { relativeTo: this.route }); | |
return false; | |
} | |
View can-match-1.ts
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' }) | |
class CanMatchNewTodos implements CanMatch { | |
constructor(private ff: FeatureFlagsService) { } | |
canMatch() { | |
return this.ff.hasPermission('todos-v2'); | |
} | |
} |
View copy-55.directive.ts
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 { fakeAsync, tick } from '@angular/core/testing'; | |
import { HotToastService } from '@ngneat/hot-toast'; | |
import { createDirectiveFactory } from '@ngneat/spectator'; | |
import { CopyDirective } from './copy.directive'; | |
describe('CopyDirective', () => { | |
const createDirective = createDirectiveFactory({ | |
directive: CopyDirective, | |
mocks: [HotToastService] | |
}); |
View copy-44.directive.ts
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, Input, NgZone } from '@angular/core'; | |
import { HotToastService } from '@ngneat/hot-toast'; | |
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; | |
import { fromEvent, switchMap } from 'rxjs'; | |
@UntilDestroy() | |
@Directive({ | |
selector: '[copy]' | |
}) | |
export class CopyDirective { |
View copy-33.directive.ts
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 { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; | |
@UntilDestroy() | |
@Directive({ | |
selector: '[copy]' | |
}) | |
export class CopyDirective { | |
@Input() copy: string; | |
constructor( |
View copy-22.directive.ts
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 { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; | |
@UntilDestroy() | |
@Directive({ | |
selector: '[copy]' | |
}) | |
export class CopyDirective { | |
@Input() copy: string; | |
constructor(private host: ElementRef<HTMLElement>) {} |
View copy-11.html
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
<button copy="Clicking this button copies this text to the clipboard"> | |
Copy | |
</button> | |
<button [copy]="fooText"> | |
Copy | |
</button> |
View new-inj-8.ts
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 function getRootComponent() { | |
return inject(AppComponent); | |
} |
View new-inj-7.ts
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
function createEntityService(store) { | |
const http = inject(HttpClient); | |
const loader = inject(NgEntityServiceLoader); | |
const notifier = inject(NgEntityServiceNotifier); | |
return new EntityService(store, http, loader, notifier); | |
} |
NewerOlder