angular-ui-router state.go not passing data to $stateParams
app.js中定义了一个state如下,url接收一个id参数
$stateProvider.state("page.details", {
url: "/details/:id",
templateUrl: "home/index.html",
controller: "HomeCtrl",
controllerUrl: "home"
})
如果直接
$state.go('details');
将会显示state.go not passing data to $stateParams
的错误信息,因为state的url中,已经规定需要传递一个id。
假如id没有值需要传递,如:
$state.go('details',{id:""});
假如需要传递id=1,如
$state.go('details',{id:1});
参考文献:
- state.go not passing data to $stateParams
- How to pass custom data in $state.go() in angular-ui-router?
- [ui-router \(stateProvider](https://ui-router.github.io/docs/0.3.1/#/api/ui.router.state.\)stateProvider#state)