angularjs - In Angular.js, where are $stateParams set? -


i learning angular.js through mean.io, has articles package example.

in articles controller see line articleid: $stateparams.articleid:

$scope.findone = function() {       articles.get({         articleid: $stateparams.articleid       }, function(article) {         $scope.article = article;       });     }; 

see full code here.

i wondering , how articleid set in $stateparams. , how $stateparams set?

update: in useful link provided samitha says: "in state controllers, $stateparams object contain params registered state."

so did articleid registered "with state"? finding code helpful.

as samitha menthoned, code uses ui-router, right?

from document, articleid set url.

https://github.com/angular-ui/ui-router/wiki/url-routing#url-parameters https://github.com/linnovate/mean/blob/master/packages/articles/public/routes/articles.js#l50

for example, when access http://<your domain>/articles/1

then $stateparams.articleid => 1.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -