【发布时间】:2014-07-30 14:06:38
【问题描述】:
当网页第一次加载时,我的指令的控制器需要知道当前选择的路由是什么。
第一次加载后,我可以使用
检测变化$scope.$on('$routeChangeSuccess', function(){});
编辑:
Answers below are valid but it didn't work for me because:
- I am new to AngularJS technology i didn't realize that, on our project, we are using custom route provider
- You need to inject 'ngRoute' in your module before you can use $route
【问题讨论】:
-
docs.angularjs.org/api/ngRoute/service/$route -> 向下滚动到“属性”部分。字面上有一个叫做“当前”的属性
标签: javascript angularjs angularjs-directive