MCPcopy
hub / github.com/angular/angular / constructor

Method constructor

packages/common/upgrade/src/location_shim.ts:64–96  ·  view source on GitHub ↗
(
    $injector: any,
    private location: Location,
    private platformLocation: PlatformLocation,
    private urlCodec: UrlCodec,
    private locationStrategy: LocationStrategy,
  )

Source from the content-addressed store, hash-verified

62 private readonly removeOnUrlChangeFn: VoidFunction;
63
64 constructor(
65 $injector: any,
66 private location: Location,
67 private platformLocation: PlatformLocation,
68 private urlCodec: UrlCodec,
69 private locationStrategy: LocationStrategy,
70 ) {
71 const initialUrl = this.browserUrl();
72
73 let parsedUrl = this.urlCodec.parse(initialUrl);
74
75 if (typeof parsedUrl === 'string') {
76 throw 'Invalid URL';
77 }
78
79 this.$$protocol = parsedUrl.protocol;
80 this.$$host = parsedUrl.hostname;
81 this.$$port = parseInt(parsedUrl.port) || DEFAULT_PORTS[parsedUrl.protocol] || null;
82
83 this.$$parseLinkUrl(initialUrl, initialUrl);
84 this.cacheState();
85 this.$$state = this.browserState();
86
87 this.removeOnUrlChangeFn = this.location.onUrlChange((newUrl, newState) => {
88 this.urlChanges.next({newUrl, newState});
89 });
90
91 if (isPromise($injector)) {
92 $injector.then(($i) => this.initialize($i));
93 } else {
94 this.initialize($injector);
95 }
96 }
97
98 private initialize($injector: any) {
99 const $rootScope = $injector.get('$rootScope');

Callers

nothing calls this directly

Calls 10

browserUrlMethod · 0.95
$$parseLinkUrlMethod · 0.95
cacheStateMethod · 0.95
browserStateMethod · 0.95
initializeMethod · 0.95
isPromiseFunction · 0.85
parseMethod · 0.65
thenMethod · 0.65
onUrlChangeMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected