2014-02-05 60 views
0

是新來的角JS ....我使用HTTP POST調用.. 寫簡單的例子,但它拋出像

未捕獲錯誤的錯誤: [$ 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) { 
      }); 

     }; 
    }); 
}); 

謝謝

+0

只是一些提示:MyApp.controller應該ang.controller在你的榜樣;您正在使用$ templateCache但不需要它 - 例如函數($ scope,$ templateCache);它直接使用$ templateCache看起來有點奇怪,並且也使用了post的請求。 – michael

回答

0

我想你想用jQuery使用IIFE for 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); 

希望它有幫助!

+0

謝謝............ –

0

你需要注入$ HTTP作爲依賴,你的控制,這樣的:

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

謝謝................ –

相關問題