angularjs controller giving Unknown Provider for $stateParams

て烟熏妆下的殇ゞ 提交于 2019-12-13 06:52:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!