Error in Chrome Developers Tool
Uncaught Error: [$injector:modulerr] Failed to instantiate module polmgr due to:
Error: [$injector:modulerr] Failed to instantiate module polmgr.controllers due to:
Error: [$injector:modulerr] Failed to instantiate module $http due to:
Error: [$injector:nomod] Module '$http' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
This error is coming when i add $http to my module in ionicframework. I am noob. I have added the $http in controllers.js file and if i remove everything works fine. but i need to make a http get call.
Find the controllers.js code below :-
angular.module('polmgr.controllers', ['$http'])
.controller('PolicyCtrl', function($scope, $http, $stateParams) {
});
Correct Code:-
angular.module('polmgr.controllers', [])
.controller('PolicyCtrl', function($scope, $http, $stateParams) {
});
From the looks of things you are trying to inject the $http
service incorrectly.
It is part of the core ng
module that angular.js/angular.min.js
provides.
So you don't need to add it as a module dependency like this:
var ctrlModule = angular.module('polmgr.controllers', [..., '$http', ...])
Instead, just inject it into your controller functions like you would do for $scope
:
.controller('PolicyCtrl', function($scope, $http, $stateParams) {
});