Dav*_*ury 7 angularjs angularjs-routing
使用ngRoute可以在事件中挂钩:$routeChangeStart
并执行不同的操作......
app.run(function ($rootScope, $location) {
$rootScope.$on("$routeChangeStart", function (event, next, current) {
................
Run Code Online (Sandbox Code Playgroud)
使用UI-Router可以实现相同的功能吗?
kar*_*una 14
是的,这是可能的:
$rootScope.$on("$stateChangeStart",
function (event, toState, toParams, fromState, fromParams) {
Run Code Online (Sandbox Code Playgroud)