Angular routeParams is undefined


I am trying to use routeParams in my JS but it always passed in as undefined.

app.controller('ShowKey', function($scope, $http, $routeParams, $log) {

  $'SomeCtrl - starting up, yeah!');

  $scope.getKey = function() {

Is there anything else what I need to set other than calling the app.controller with routeParams?

Problem courtesy of: Istvan


1- Have you consider any routeParams in your config anyway ? 2- if you want to get your routeParams in your config , well , you cant,

---you must use :

$route.current.params , instead

       templateUrl:"your template url address",
        controller:'your controller',
        resolve: {
            resolbeObject: function($route){
             //**here you cannot use $routeParam to get "yourRouteParam"** property
            // you must use : $route.current.params

But in your controller you can get yourRouteParam with $route.params , just if you have defined route params in your route confige like this :


NOTE if you want to define any route param you must use(:), not (?)

Solution courtesy of: Milad


There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.