0

I´m want to send parameters with $state.go as:

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

And I passing as parameter as:

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

Into angular controller I injected dependencies like this:

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

problem occurs when I use add $stateParams just like:

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

It throwing issue in console saying:

$state is undefined

I don´t understand what is wrong, why my $stateParams conflict $state definition. Can someone explain me please?

Ledwing
  • 311
  • 2
  • 10
  • This may answer your question: https://stackoverflow.com/q/23081397/215552 – Heretic Monkey Jul 19 '17 at 21:00
  • I dont see any problem can you share some plnkr or fiddle to see the error. – Jesus Carrasco Jul 19 '17 at 21:37
  • I rewrite my question, can you check it please ? @JesusCarrasco – Ledwing Jul 19 '17 at 21:46
  • @Ledwing var catPadre = $scope.catalogoPadre; $state.go("root.catalogosgenericos", catPadre); should be $state.go('root.catalogosgenericos', {catPadre: $scope.catalogoPadre}); or $state.go('root.catalogosgenericos',{catPadre: catPadre}'); based on the variable catPadre. Check changing on those notation. – Jesus Carrasco Jul 19 '17 at 22:00

1 Answers1

1

try using below solution:

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

In your route file change the code like below:

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

                 authenticate: true
             })

Change your controller function:

function catalogosGenericosCtrl($scope, apiService, notificationService, $rootScope, $location,  $http, $state,$stateParams, $filter) {
Tejinder Singh
  • 1,070
  • 2
  • 8
  • 24