angularjs - can't access the returned correctly returned $routeParams using a dot (.) -


i think problem accesssing code works fine until line tried log $routeparams , returned shown cant access dot specific attributes

                var myapp = angular.module('myapp', ['nggrid', 'ngroute', "nganimate", "ngaria", 'ngmaterial']);             var statuslabel;             var selecteditem;              myapp.config(['$routeprovider', function ($routeprovider)             {                 $routeprovider.                 when('/:energyid/:energychain/:resourceid/:facilityid',                 {                     templateurl: '/content/resourcetemplate.html',                     controller: 'detailscontroller'                  }).                 otherwise({                     redirectto: '/param1/param1/param1/param1'                 });             }]);              myapp.controller('detailscontroller', ['$scope', '$routeparams', function ($scope, $routeparams) {                 //after testing following code returns   {"energyid":"param1","energychain":"param1","resourceid":"param1","facilityid":"param1"}  matching url                 //but when try access $routeparams.energyid undefined problems seems accessing returned value                  $scope.statuslabel = $routeparams;                 //this error                 $scope.label = $routeparams.energyid; 

**the error accessing details in routeparams **

from angular documentation $routeprovider

be aware ngroute.$routeparams still refer previous route within these resolve functions. use $route.current.params access new route parameters, instead.

so..

$scope.label =  $route.current.params.energyid; 

referred from


Comments