这可能听起来很奇怪,但我需要检查控制器中的当前路由路径。我无法找到答案。
我有 3 条路线:默认的“/”、“报告”和“预览”。
如何检查控制器中的路线?
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
}
Run Code Online (Sandbox Code Playgroud)
小智 6
该$location服务有两种您可以使用的$location.path()方法$location.url()
AngularJS 文档应该足够清晰:
| 归档时间: |
|
| 查看次数: |
9725 次 |
| 最近记录: |