AngularJS AJAX - $http

· 8년 전 · 1211
AngularJS AJAX - $http

$ http 는 원격 서버에서 데이터를 읽는 AngularJS 서비스입니다.


AngularJS $ http
AngularJS $http서비스는 서버에 요청을 보내고 응답을 반환합니다.



서버에 간단한 요청을하고 결과를 헤더에 표시하십시오.

<div ng-app="myApp" ng-controller="myCtrl">

<p>Today's welcome message is:</p>
<h1>{{myWelcome}}</h1>

</div>

<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
$http.get("welcome.htm")
.then(function(response) {
$scope.myWelcome = response.data;
});
});
</script>

[전체소스]
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>

<div ng-app="myApp" ng-controller="myCtrl">

<p>Today's welcome message is:</p>

<h1>{{myWelcome}}</h1>

</div>

<p>The $http service requests a page on the server, and the response is set as the value of the "myWelcome" variable.</p>

<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
$http.get("welcome.htm")
.then(function(response) {
$scope.myWelcome = response.data;
});
});
</script>

</body>
</html>
|
댓글을 작성하시려면 로그인이 필요합니다.

퍼블리싱강좌

+
분류 제목 글쓴이 날짜 조회
AngularJS 8년 전 조회 1,990
AngularJS 8년 전 조회 1,567
AngularJS 8년 전 조회 1,216
AngularJS 8년 전 조회 1,523
AngularJS 8년 전 조회 1,304
AngularJS 8년 전 조회 1,116
AngularJS 8년 전 조회 2,088
AngularJS 8년 전 조회 1,159
AngularJS 8년 전 조회 1,225
AngularJS 8년 전 조회 1,417
AngularJS 8년 전 조회 1,270
AngularJS 8년 전 조회 1,463
AngularJS 8년 전 조회 1,470
AngularJS 8년 전 조회 1,244
AngularJS 8년 전 조회 1,212
AngularJS 8년 전 조회 1,616
AngularJS 8년 전 조회 1,595
AngularJS 8년 전 조회 1,441
AngularJS 8년 전 조회 1,314
AngularJS 8년 전 조회 1,751
AngularJS 8년 전 조회 1,204
AngularJS 8년 전 조회 1,604
AngularJS 8년 전 조회 1,532
AngularJS 8년 전 조회 1,234
AngularJS 8년 전 조회 1,775
AngularJS 8년 전 조회 1,797
AngularJS 8년 전 조회 1,225
AngularJS 8년 전 조회 1,387
AngularJS 8년 전 조회 1,502
AngularJS 8년 전 조회 1,297