angularjs - $stateParams returning undefined -


i have these routes defined:

    .state('sport',       url: '/sport'       templateurl: '/templates/sport'       controller: 'sportctrl'     )     .state('sport.selected'       url: '/:sport'       templateurl: '/templates/sport'       controller: 'sportctrl'     ) 

and have controller trying use :sport param given sport.selected state.

     angular.module('myapp')        .controller('sportctrl', ['$scope', 'parseservice',                     '$stateparams', function ($scope, parseservice, $stateparams) {            var sporturl = $stateparams.sport;        ...     }); 

for reason, returns undefined when call $stateparams.sport in controller, though think defined in routes. why case?

thanks help!

when access url /sport/12, sportctrl instantiated twice: once state sport, , once state sport.selected. , first state, there no parameter associated state, $stateparams.sport undefined.

note it's quite strange use same template state , sub-state. you'll have template embedded inside ui-view div of same template.


Comments

Popular posts from this blog

javascript - How to name a jQuery function to make a browser's back button work? -

collision detection - C++ library for mesh to mesh intersection: what is available? -

python - Django-easy-pdf: xhtml2pdf reporting reportlab 2.2+ is required, but 3.0 installed -