angularJS +离子。无法解决状态

时间:2016-01-17 18:13:01

标签: angularjs ionic-framework angular-ui-router

你好,我有1个控制器的差异状态。看起来像这样:

        .state('new-orders', {
        url: "/new-orders",
        templateUrl: "views/new-orders.html",
        controller: 'OrderCtrl',
        cache: false
    })

    .state('view-order', {
        url: "/view-order/:orderid",
        templateUrl: "views/view-order.html",
        controller: 'OrderCtrl',
        cache: false
    })

    .state('open-orders', {
        url: "/open-orders",
        templateUrl: "views/open-orders.html",
        controller: 'OrderCtrl',
        cache: false
    })

    .state('completed-orders', {
        url: "/completed-orders",
        templateUrl: "views/completed-orders.html",
        controller: 'OrderCtrl',
        cache: false
    });

现在,当用户处于州新订单状态时,用户可以打开订单。我是这样做的:

    $scope.goToOrder = function(orderid) {
    $state.go('view-order/:orderid/',{orderid:orderid});
    }

但出于某种原因,当调用goToOrder时,我得到了这个回复:

Error: Could not resolve 'view-order/:orderid/' from state 'new-orders'

1 个答案:

答案 0 :(得分:1)

$ state.go接受州名而不是网址。

试试这个:

$scope.goToOrder = function(orderid) {
    $state.go('view-order',{orderid:orderid});
}