저는 AngularJS를 처음으로 사용해 보았습니다. $http.post("url", data)
기능을 사용할 때 Error: $http is not defined
콘솔 메시지가 나타납니다.
내 HTML 페이지 맨 위에 다른 모든 JS 가져 오기 후에 AngularJS가 포함됩니다.
나는 또한 위젯으로 인해 다른 자바 스크립트 라이브러리를 포함했다의존성 등 내 스크립트 수입 섹션은 다음과 같습니다
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
<script src="http://www.trirand.com/blog/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="http://www.trirand.com/blog/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js"></script>
내가 서버에 일부 데이터를 전송하기 위해 사용하고 컨트롤러를 가지고 :
function FormCtrl($scope) {
$scope.sendData = function(){
var data = "firstName=" + $scope.firstName + "&" +
"lastName=" + $scope.lastName + "&" +
"address=" + $scope.address + "&" +
"postcode=" + $scope.postcode;
$http.post("/data/person/put", data);
};
}
버튼에 sendData
기능이 첨부되어 있습니다. 콘솔에서 오류를 출력하는 $http.post(...)
을 호출 할 때까지 모두 제대로 작동합니다.
전체 오류 목록은 다음과 같습니다
Error: $http is not defined
[email protected]://localhost:8080/angularjs/:96
Mc/x/<@https://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js:71
ec[c]</</</<@https://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js:142
[email protected]://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js:87
[email protected]://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js:87
ec[c]</</<@https://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js:142
[email protected]://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js:63
c.event.add/[email protected]://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js:57
https://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js
Line 61
내가 $http.post
기능을 사용 AngularJS와를 구성하는 다른 일을해야합니까? http://docs.angularjs.org/api/ng.$http
사람이 도와 드릴까요 :
은 내가 AngularJS와에서 바로 여기에 문서의 바로 가기 방법 섹션을 사용을 해제?
감사 아담
를 참조하십시오. 빠른 응답에 감사드립니다. 너무 빨리 나는 당신의 대답을 아직 받아들이지 못합니다. 그러나 전 할겁니다. 다시 한 번 감사드립니다! –
http://docs.angularjs.org/tutorial/step_05에서 사료 주입시 합병증에 대한 메모를 읽을 수 있습니다. –