得到一个错误:未捕获的错误:[$ injector:modulerr]

时间:2014-02-05 07:15:52

标签: angularjs

是角度js的新手....我使用http post call写了一个简单的例子.. 但它会抛出像

这样的错误

未捕捉错误:[$ injector:modulerr] http://errors.angularjs.org/1.2.3/ $ injector / modulerr?p0 = MyApp& p1 =错误%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) {
            });

        };
    });
});

谢谢

2 个答案:

答案 0 :(得分:0)

我想你想用IIFE和jQuery一起用于angualarjs。所以我修改了以下代码

(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); 

希望它有所帮助!

答案 1 :(得分:0)

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

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