AngularJS调用API导致注入错误
当我尝试使用$ http从我的应用中的API获取值时,发生注入错误。 我包含模块定义的代码和调用Web API的函数以及浏览器控制台中的错误。
angular.module('mod-1').controller('Controller', ['$scope','http', 'APICM', '$q', '$filter', '$timeout', 'AppSettings'$modal', 'Dialog', 'title',
function ($scope, $http, API, $q, $filter, $timeout, AppSettings, $modal, Dialog, title) {
$('.page-title').text(title);
function getActiveStore() {
$http.get("https://localhost:44300/api/store/active").success(
function (response) {
$scope.currentStore = response;
})
}
}
错误:Error:[$ injector:unpr] http://errors.angularjs.org/undefined/$injector/unpr?p0=httpProvider%20%3C-%20http at Error(native)at https:// localhost:44300 /scripts/vendor/angular.min.js:6:453 at https:// localhost:44300 / Scripts / vendor / angular.min.js:32:18在Object.c中[as get](https:// localhost :https:// localhost:44300 / Scripts / vendor / angular.min.js:32:86 at c(https:// localhost:44300/44300 / Scripts / vendor / angular.min.js:29:147) (https:// localhost:44300 / Scripts / vendor / angular.min.js:29:324)在Object.instantiate(https:// localhost: 44300 / Scripts / vendor / angular.min.js:30:482)https:// localhost:44300 / Scripts / vendor / angular.min.js:59:495在https:// localhost:44300 / Scripts / vendor /angular-route.min.js:6:446
声明'$ http'时你忘了$:
angular.module('mod-1').controller('Controller', ['$scope','$http', 'APICM', '$q', '$filter', '$timeout', 'AppSettings', '$modal', 'Dialog', 'title',
function ($scope, $http, API, $q, $filter, $timeout, AppSettings, $modal, Dialog, title) {
$('.page-title').text(title);
function getActiveStore() {
$http.get("https://localhost:44300/api/store/active").success(
function (response) {
$scope.currentStore = response;
})
}
}
这应该解决你所得到的错误。
链接地址: http://www.djcxy.com/p/13603.html