我在我的应用程序中使用角度$routeProvider来更改网址。我想获取前一个url并替换它的一些路由参数。
$routeProvider.when("/editUser/:userId", {
templateUrl: "app/user/userEdit.html",
controller: "UserCtrl"
});
例如,如果我之前的网址是上面的网址,我想将其参数userId
更改为其他内容。 (上一个网址:/editUser/1
,我想将其更改为:/editUser/2
)
我可以使用AngularJS做类似的事吗?
答案 0 :(得分:0)
您可以为此目的使用角度路线更改事件,例如
$routeChangeStart, $routeChangeSuccess, $routeChangeError, $routeUpdate
这是一个例子
$rootScope.$on('$routeChangeStart', function(event, next, current) {
console.log("Next - " + next.$$route.originalPath);
console.log("Current - " + current.$$route.originalPath);
});
您可以将其存储在任何范围值中。