当$ state.go的passimg参数时,$ stateParams与$ state冲突

时间:2017-07-19 20:56:27

标签: angularjs

我想将参数$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) {
当我使用add $ stateParams时会出现

问题:

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

它在控制台中抛出问题说:

  

$ state未定义

我不明白错误,为什么我的$stateParams冲突$state定义。有人可以解释一下吗?

1 个答案:

答案 0 :(得分: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) {
相关问题