2017-07-19 43 views
0

I'm希望與$state.go發送參數爲:

var catPadre = $scope.catalogoPadre; 
$state.go("root.catalogosgenericos", catPadre); 

我傳遞的參數爲:

.state('root.catalogosgenericos', { 
       url: "catalogosGenericos.html/", 
       templateUrl: "../SPA/administrador/catalogos/catalogosGenericos.html", 
       controller: "catalogosGenericosCtrl", 
       params: { 
        catPadre: null 
       }, 
       authenticate: true 
      }) 

進入角度控制器我注入這樣的依賴:

function catalogosGenericosCtrl($scope, apiService, notificationService, $rootScope, $location, $http, $state, $filter) { 

問題發生時,我使用添加$ stat eParams就像:

function catalogosGenericosCtrl($scope, apiService, notificationService, $rootScope, $location, $stateParams, $http, $state, $filter) { 

它扔在控制檯的問題說:

$狀態不定

我不明白什麼是錯的,爲什麼我的$stateParams衝突$state定義。有人可以解釋我嗎?

+0

這可能會回答你的問題: https://stackoverflow.com/q/23081397/215552 –

+0

我沒有看到任何問題,你可以分享一些plnkr或fidd le看到錯誤。 –

+0

我重寫我的問題,可以檢查一下嗎? @JesusCarrasco – Ledwing

回答

1

嘗試使用以下解決方案:

var catPadre = $scope.catalogoPadre; 
$state.go("root.catalogosgenericos", {catPadre:$scope.catalogoPadre}); 

在你的路由文件改變如下面的代碼:

.state('root.catalogosgenericos', { 
       url: "/catalogosGenericos/ :catPadre", 
       templateUrl: "../SPA/administrador/catalogos/catalogosGenericos.html", 
       controller: "catalogosGenericosCtrl", 

       authenticate: true 
      }) 

更改您的控制器功能:

function catalogosGenericosCtrl($scope, apiService, notificationService, $rootScope, $location, $http, $state,$stateParams, $filter) { 
+0

讓我知道如果仍然沒有工作 –

+0

它的工作。謝謝 – Ledwing

+0

@Ledwing你也可以投我的問題。\ –