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});

参考文献:

  1. state.go not passing data to $stateParams
  2. How to pass custom data in $state.go() in angular-ui-router?
  3. [ui-router \(stateProvider](https://ui-router.github.io/docs/0.3.1/#/api/ui.router.state.\)stateProvider#state)
posted @ 2016-10-21 00:22  五毛钱的饼  阅读(240)  评论(0编辑  收藏  举报