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

Method constructor

packages/common/upgrade/src/location_shim.ts:62–94  ·  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

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