MCPcopy Create free account
hub / github.com/angular/components / constructor

Method constructor

docs/src/app/material-docs-app.ts:42–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40 private _headerTagManager = inject(HeaderTagManager);
41
42 constructor() {
43 const analytics = inject(AnalyticsService);
44 const navigationFocusService = inject(NavigationFocusService);
45 const router = inject(Router);
46
47 this._subscriptions.add(
48 navigationFocusService.navigationEndEvents
49 .pipe(
50 map(e => e.urlAfterRedirects),
51 startWith(''),
52 pairwise(),
53 )
54 .subscribe(([fromUrl, toUrl]) => {
55 // We want to reset the scroll position on navigation except when navigating within
56 // the documentation for a single component.
57 if (!navigationFocusService.isNavigationWithinComponentView(fromUrl, toUrl)) {
58 resetScrollPosition();
59 }
60 analytics.locationChanged(toUrl);
61 }),
62 );
63
64 router.events
65 .pipe(
66 filter((e): e is NavigationEnd => e instanceof NavigationEnd),
67 map(event => event.urlAfterRedirects),
68 )
69 .subscribe(url => {
70 this._updateCanonicalLink(url);
71 });
72 }
73
74 ngOnDestroy() {
75 this._subscriptions.unsubscribe();

Callers

nothing calls this directly

Calls 5

_updateCanonicalLinkMethod · 0.95
resetScrollPositionFunction · 0.85
locationChangedMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected