Uncaught Error: [$injector:modulerr] Failed to instantiate module polmgr due to
Uncaught Error: [$injector:modulerr] Failed to instantiate module polmgr due to
Chrome 开发者工具出错
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.
当我在 ionicframework 中将 $http 添加到我的模块时出现此错误。
我是菜鸟。
我在 controllers.js 文件中添加了 $http,如果我删除一切正常。但我需要打一个 http get 电话。
找到下面的 controllers.js 代码:-
angular.module('polmgr.controllers', ['$http'])
.controller('PolicyCtrl', function($scope, $http, $stateParams) {
});
正确代码:-
angular.module('polmgr.controllers', [])
.controller('PolicyCtrl', function($scope, $http, $stateParams) {
});
从表面上看,您正试图错误地注入 $http
服务。
它是 angular.js/angular.min.js
提供的核心 ng
模块的一部分。
所以你不需要像这样将其添加为模块依赖项:
var ctrlModule = angular.module('polmgr.controllers', [..., '$http', ...])
相反,只需像 $scope
:
那样将其注入到您的控制器函数中
.controller('PolicyCtrl', function($scope, $http, $stateParams) {
});
Chrome 开发者工具出错
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.
当我在 ionicframework 中将 $http 添加到我的模块时出现此错误。 我是菜鸟。 我在 controllers.js 文件中添加了 $http,如果我删除一切正常。但我需要打一个 http get 电话。
找到下面的 controllers.js 代码:-
angular.module('polmgr.controllers', ['$http'])
.controller('PolicyCtrl', function($scope, $http, $stateParams) {
});
正确代码:-
angular.module('polmgr.controllers', [])
.controller('PolicyCtrl', function($scope, $http, $stateParams) {
});
从表面上看,您正试图错误地注入 $http
服务。
它是 angular.js/angular.min.js
提供的核心 ng
模块的一部分。
所以你不需要像这样将其添加为模块依赖项:
var ctrlModule = angular.module('polmgr.controllers', [..., '$http', ...])
相反,只需像 $scope
:
.controller('PolicyCtrl', function($scope, $http, $stateParams) {
});