当使用$ state.go或ui-sref时,使用可选的{parameter}时,UI-Router解析条目重新加载两次,并且未填充可选参数。
.state('dashboard.loan', {
url: "/loan/:type/{instanceid}",
templateUrl: '/app/dashboard/views/package.html',
controller: 'PackageController',
controllerAs: 'packageCtrl',
resolve: {
UserAuth: session
}
})
// Resolves only once when both parameters are provided
$state.go( 'dashboard.loan',
{ packageType: packageType,
packageInstanceId: packageInstanceId } );
// Resolves twice when only one parameters is provided
$state.go( 'dashboard.loan',
{ packageType: packageType } );
我正在使用ui-router v0.2.11。任何想法,似乎都无法找到解决方案。
v0.2.11的解决方案 不要使用可选花括号查询参数