$routeParams gets undefined in angularjs? $routeParams gets undefined in angularjs? wordpress wordpress

$routeParams gets undefined in angularjs?


Try changing $routeParams with $stateParams in every instance. You're obviously using ui-router which uses "states", while ngRouter uses "routes".

angular.module('myapp').controller('CategoriesCtrl', ['$scope', '$http',  function($scope, $http) {    $http.get("~/wp/v2/terms/category")      .then(function(res) {        $scope.categories = res.data;      })  }]).controller('PostCtrl', ['$scope', '$http', '$stateParams',  function($scope, $http, $stateParams) {    $http.get("~/wp/v2/terms/category/" + $stateParams.category).success(function(res) {      $scope.current_category_id = $stateParams.category;      console.log($stateParams.category);      $scope.pageTitle = 'Posts in ' + res.data.name + ':';      document.querySelector('title').innerHTML = 'Category: ' + res.data.name + ' | AngularJS Demo Theme';      $http.get("~/wp/v2/posts/?filter[category_name]=" + res.data.name).success(function(res) {        $scope.posts = res.data;        console.log($scope.posts);      })    })  }]);


You might want to double-check the code near

.controller('PostCtrl', ['$scope','$http','$rootScope', function($scope, $http, $routeParams)

it should be

.controller('PostCtrl', ['$scope','$http','$rootScope', '$routeParams', function($scope, $http, $rootScope, $routeParams)

Read more here on syntax of creating a Controller. You are missing injectors.