Angularjs 获取错误,如:未捕获错误:[$injector:moduler]

Angularjs 获取错误,如:未捕获错误:[$injector:moduler],angularjs,Angularjs,我是angular js新手……我使用http post调用编写了一个简单的示例。。 但它会抛出一个错误,比如 未捕获错误:[$injector:modulerr]$injector/modulerr?p0=MyApp&p1=Error%3A%2…tps%3A%2F%2Ftestvendor.planotest.com%2FScripts%2Fangular.min.js%3A17%3A315) 下面给出了我的js代码 $(function () { var ang = angular

我是angular js新手……我使用http post调用编写了一个简单的示例。。 但它会抛出一个错误,比如

未捕获错误:[$injector:modulerr]$injector/modulerr?p0=MyApp&p1=Error%3A%2…tps%3A%2F%2Ftestvendor.planotest.com%2FScripts%2Fangular.min.js%3A17%3A315)

下面给出了我的js代码

$(function () {

    var ang = angular.module('MyApp', []);

    MyApp.controller('tagReports', function ($scope) {
        $scope.CustomerTagID = _TagID;
        $scope.listOfTags = [];
        $scope.tagList = [];

        $scope.LoadCustomerDetails = function () {

            $http({ method: " post", url: "/LeadManagement/Customer/GetCustomerDetailsListByTag/" + viewModel.CustomerTagID(), cache: $templateCache }).
            success(function (data) {
            }).
            error(function (data, status) {
            });

        };
    });
});

谢谢你

我想你想用iLife为angualarjs和jQuery一起使用。因此,我修复了如下代码

(function ($) {

var MyApp = angular.module('MyApp', []);

MyApp.controller('tagReports', function ($scope, $http, $templateCache) {

    $scope.CustomerTagID = _TagID;
    $scope.listOfTags = [];
    $scope.tagList = [];

    $scope.LoadCustomerDetails = function () {

        $http({ method: " post", url: "/LeadManagement/Customer/GetCustomerDetailsListByTag/" + viewModel.CustomerTagID(), cache: $templateCache }).
        success(function (data) {
        }).
        error(function (data, status) {
        });
    };
});
})(jQuery); 

希望有帮助

您需要将$http作为依赖项注入控制器,如下所示:

MyApp.controller('tagReports', function ($scope, $http) {});

只是一些提示:在您的示例中,MyApp.controller应该是ang.controller;您正在使用$templateCache,但不需要它-例如,函数($scope,$templateCache);直接使用$templateCache和使用post请求看起来有点奇怪。