2016-01-17 99 views
0

你好,我有1個控制器的diffrents狀態。看起來像這樣:angularJS +離子。無法解析狀態

 .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

$ state.go接受的狀態名稱不是URL。

試試這個:

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