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; }); };
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
Post a Comment