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

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

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