I am new to angular js, I am creating a test application to understand the flow, however when I try to use $ stateParams my controller does not load, I get an error in the console that redirects me to https://docs.angularjs.org / error / $ injector / unpr? p0 = where I can see this
Error: Error: unpr Unknown provider
My controller looks below
angular.module('NerdCtrl', []).controller('NerdController', ["$scope","$stateParams", "Nerd", function($scope, $stateParams, Nerd) {
$scope.getAll = function() {
Nerd.get().success(function(data, res) {
$scope.nerds = data
})
}
$scope.saveNerd = function(nerd){
Nerd.create(nerd).success(function(data, res){
console.log(data)
});
}
$scope.getNerd = function(){
console.log($stateParams.id)
}
}]);
Nerd is a factory that I created for services
If I do not include $ stateParams, then everything works fine as expected.
source
share