[英]AngularJS current route path?
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". 我有3条路线:默认的“ /”,“报告”和“预览”。
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()
$location
服务有两种方法可以使用$location.path()
和$location.url()
The AngularJS documentation should be clear enough: AngularJS文档应该足够清楚:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.