angularjs - $routeProvider not loading template when url has a parameter -
i have use angular's $routeprovider
load templates using code similar this
$routeprovider.when('/store', { templateurl: 'views/store.html', controller: 'storecontroller' });
however, when use code below nothing happens. is, template not loaded. think must because have parameter in url, i'm not sure.
$routeprovider.when('/item/:item_id/info', { templateurl: 'views/item.html', controller: 'itemsctrl' });
how can work?
update: clear, links this: ng-click="setroute('/item/1/info')"
"1" parameter.
update2:
$scope.setroute = function(route){ $location.path(route); };
update3:
the parameter :item_id
being loaded via $http
. when inspect source code page see parameter (e.g., "123"), reason not bound setroute
function. if hard code parameter works, don't want hard code it. how can bind url parameter works?
you need make partials absolute in:
templateurl: '/views/item.html',
when parameter added looks @ depth of directory , wants load /item/views/item.html
Comments
Post a Comment