當我使用jQuery的$.ajax
它的工作原理每次,但是當我回來Angularjs我寫
test.js
:
var readContracts = function($scope, $http){
$http({method: 'GET', url: 'http://test.url.com/contracts'}).
success(function(data, status, headers, config) {
$scope.contracts = angular.fromJson(data);
}).
error(function(data, status, headers, config) {
debugger;
// called asynchronously if an error occurs
// or server returns response with an error status.
});
};
的test.html:
<!DOCTYPE html>
<html ng-app>
<head>
<meta charset="UTF-8">
<title>test</title>
</head>
<body>
<button ng-click="readContracts()">readContracts</button>
<ul>
<li ng-repeat="contract in contracts"> {{contract | json}} </li>
</ul>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js"></script>
<script src="test.js"></script>
</body>
</html>
而且它永遠不會奏效。甚至在Chrome的調試程序:-(
的請求可能的專家可以在幾秒鐘內我做錯了什麼看?
的Merci beaucoup爲了您的編輯,我在這段時間學到了很多東西,還有如何提問Stackoverflow – LeGilles