Reputation: 1362
I'm looking for a way to receive the current server path as a string in Angular2, i.e.
http://localhost:3000/my/dynamic/path
How can I get: /my/dynamic/path
Upvotes: 0
Views: 170
Reputation: 657068
This should do it the Angular way
export class AppComponent {
constructor(private location:Location) {}
repoPath: string;
ngOnInit() {
this.repoPath = location.path();
}
}
Upvotes: 1
Reputation: 1362
Found it already:
export class AppComponent {
repoPath: string;
ngOnInit() {
this.repoPath = window.location.pathname;
}
}
Upvotes: 0