this may sound strange, but I need to check for current route path in my controller. I wasnt able to find the answer.
I have 3 routes: the default "/", "Report" and "Preview".
How can I check the route in the controller?
constructor(
private dataService: DataService,
private $scope: ng.IScope,
private $location: ng.ILocationService,
private $route, // what type should it be (for typescript)?
private $routeParams: IRouteParams,
private $log: ng.ILogService) {
var xxx = $route.current; // doesnt work, undefined always
}
The $location
service has two methods you can use $location.path()
and $location.url()
The AngularJS documentation should be clear enough:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.