gpt4 book ai didi

javascript - $routeParams 在 $locationChangeSuccess 上为空

转载 作者:行者123 更新时间:2023-11-30 07:38:28 25 4
gpt4 key购买 nike

我在以下运行 block 中配置我的应用程序。基本上我想执行一个操作,要求我知道每个 $locationChangeSuccess$routeParams

然而 $routeParams 此时是空的! 是否有工作轮次?这是怎么回事?

app.run(['$routeParams', function ($routeParams) {

$rootScope.$on("$locationChangeSuccess", function () {
console.log($routeParams);
});

}]);

更新

function configureApp(app, user) {

app.config(['$routeProvider', function ($routeProvider) {
$routeProvider.
when('/rentroll', {
templateUrl: 'rent-roll/rent-roll.html',
controller: 'pwRentRollCtrl'
}).

when('/bill', {
templateUrl: 'bill/bill/bill.html',
controller: 'pwBillCtrl'
}).

when('/fileroom', {
templateUrl: 'file-room/file-room/file-room.html',
controller: 'pwFileRoomCtrl'
}).

when('/estate-creator', {
templateUrl: 'estate/creator.html'
}).

when('/estate-manager', {
templateUrl: 'estate/manager.html',
controller: 'pwEstateManagerCtrl'
}).

when('/welcomepage', {
templateURL: 'welcome-page/welcome-page.html',
controller: 'welcomePageCtrl'
}).

otherwise({
redirectTo: '/welcomepage'
});
}]);

app.run(['$rootScope', '$routeParams', 'pwCurrentEstate','pwToolbar', function ($rootScope, $routeParams, pwCurrentEstate, pwToolbar) {

$rootScope.user = user;



$rootScope.$on("$locationChangeSuccess", function () {
pwToolbar.reset();
console.log($routeParams);
});

}]);

}

访问地址:

http://localhost:8080/landlord/#/rentroll?landlord-account-id=ahlwcm9wZXJ0eS1tYW5hZ2VtZW50LXN1aXRlchwLEg9MYW5kbG9yZEFjY291bnQYgICAgICAgAoM&billing-month=2014-06

最佳答案

这对我有用,在你的运行回调中:

.run(function($rootScope, $routeParams, $location) {
$rootScope.$on("$locationChangeSuccess", function() {
var params = $location.search();
console.log(params);
console.log('landlord-account-id:', params['landlord-account-id']);
console.log('billing-month', params['billing-month']);
});
})

关于javascript - $routeParams 在 $locationChangeSuccess 上为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24132232/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com