问题
I am new to angular js, I am creating a test app to understand the flow, however when I am trying to use $stateParams then my controller is not loading, in console I am getting the error message which is redirecting me to https://docs.angularjs.org/error/$injector/unpr?p0= where I am able to see this
Error: error:unpr Unknown Provider
My controller looks like 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 which I have created for services
If I am not including $stateParams then everything is working fine as expected.
来源:https://stackoverflow.com/questions/29059759/angularjs-controller-giving-unknown-provider-for-stateparams