我想将参数$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
定义。有人可以解释一下吗?
答案 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) {