javascript - Angular - $stateparams always undefined -
im trying use stateparams filter ng-repeat. im trying create user profile pages when visits url
http://localhost:3000/users/johnexample they see list of johnexample's "savings". if visit url can see profile page fine param doesnt initialise.
im trying setup controller variable filter using
$scope.usernamevalue = $stateparams.username; thats undefined when visit url
client controller
angular.module('savings').controller('savingscontroller', ['$scope', '$http', '$stateparams','$state' , 'users', function($scope, $stateparams, $window, $state, $http, authentication, users) { $scope.usernamevalue = $stateparams.username; ]); route
app.route('/api/savings/of/:username') .get(savings.listof); server controller
exports.listof = function(req, res) { saving.find( { user: req.params.userid }).sort('-created').exec(function(err, posts) { if (err) { return res.status(400).send({ message: errorhandler.geterrormessage(err) }); } else { console.log(req.params.userid); res.jsonp(posts); } }); }; is there else missing this?
thanks
when you're injecting dependencies in angular, order of function arguments needs match order of strings in array. stands you're injecting $http service name $stateparams, hence error.
Comments
Post a Comment