Wednesday, March 28, 2018

Use the Location in @angular/common to get the route/URL as a magic string in Angular 4!

Import:

import { Location } from '@angular/common';

 
 

Fish out what you need like so:

constructor(location: Location) {
   this.whereAmI = location.path();
}

No comments:

Post a Comment