AngularJS Data Binding 2번째
AngularJS Data Binding
ng-model지침
ng-model지시문을 사용하여 모델의 데이터를 HTML 컨트롤의보기에 바인딩합니다 (input, select, textarea).
예
<input ng-model="firstname">
이 ng-model지시문은 모델과 뷰간에 양방향 바인딩을 제공합니다.
양방향 바인딩
AngularJS에서의 데이터 바인딩은 모델과 뷰 간의 동기화입니다.
의 데이터 때 모델 변경은 보기 의 변화를 반영하고, 데이터 때 뷰 변경은 모델 도 업데이트됩니다. 이는 즉시 자동으로 발생하므로 모델과 뷰가 항상 업데이트됩니다.
예
<div ng-app="myApp" ng-controller="myCtrl">
Name: <input ng-model="firstname">
<h1>{{firstname}}</h1>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.firstname = "John";
$scope.lastname = "Doe";
});
</script>
각도 컨트롤러
AngularJS의 응용 프로그램은 컨트롤러에 의해 제어됩니다. AngularJS Controllers 장의 컨트롤러에 대해 읽어보십시오 .
모델과 뷰의 즉각적인 동기화로 인해 컨트롤러는 뷰와 완전히 분리되어 모델 데이터에만 집중할 수 있습니다. AngularJS의 데이터 바인딩 덕분에 뷰는 컨트롤러에서 변경 한 내용을 반영합니다.
예
<div ng-app="myApp" ng-controller="myCtrl">
<h1 ng-click="changeName()">{{firstname}}</h1>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.firstname = "John";
$scope.changeName = function() {
$scope.firstname = "Nelly";
}
});
</script>
ng-model지침
ng-model지시문을 사용하여 모델의 데이터를 HTML 컨트롤의보기에 바인딩합니다 (input, select, textarea).
예
<input ng-model="firstname">
이 ng-model지시문은 모델과 뷰간에 양방향 바인딩을 제공합니다.
양방향 바인딩
AngularJS에서의 데이터 바인딩은 모델과 뷰 간의 동기화입니다.
의 데이터 때 모델 변경은 보기 의 변화를 반영하고, 데이터 때 뷰 변경은 모델 도 업데이트됩니다. 이는 즉시 자동으로 발생하므로 모델과 뷰가 항상 업데이트됩니다.
예
<div ng-app="myApp" ng-controller="myCtrl">
Name: <input ng-model="firstname">
<h1>{{firstname}}</h1>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.firstname = "John";
$scope.lastname = "Doe";
});
</script>
각도 컨트롤러
AngularJS의 응용 프로그램은 컨트롤러에 의해 제어됩니다. AngularJS Controllers 장의 컨트롤러에 대해 읽어보십시오 .
모델과 뷰의 즉각적인 동기화로 인해 컨트롤러는 뷰와 완전히 분리되어 모델 데이터에만 집중할 수 있습니다. AngularJS의 데이터 바인딩 덕분에 뷰는 컨트롤러에서 변경 한 내용을 반영합니다.
예
<div ng-app="myApp" ng-controller="myCtrl">
<h1 ng-click="changeName()">{{firstname}}</h1>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.firstname = "John";
$scope.changeName = function() {
$scope.firstname = "Nelly";
}
});
</script>
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 88 | jQuery Mobile | 8년 전 | 1924 | ||
| 87 | jQuery Mobile | 8년 전 | 1910 | ||
| 86 | jQuery Mobile | 8년 전 | 1515 | ||
| 85 | jQuery Mobile | 8년 전 | 1825 | ||
| 84 | jQuery Mobile | 8년 전 | 1863 | ||
| 83 | jQuery Mobile | 8년 전 | 1875 | ||
| 82 | jQuery Mobile | 8년 전 | 1647 | ||
| 81 | jQuery Mobile | 8년 전 | 1368 | ||
| 80 | jQuery Mobile | 8년 전 | 1804 | ||
| 79 | jQuery Mobile | 8년 전 | 1355 | ||
| 78 | jQuery Mobile | 8년 전 | 1750 | ||
| 77 | jQuery Mobile | 8년 전 | 1776 | ||
| 76 | jQuery Mobile | 8년 전 | 1784 | ||
| 75 | jQuery Mobile | 8년 전 | 1398 | ||
| 74 | jQuery Mobile | 8년 전 | 1535 | ||
| 73 | jQuery Mobile | 8년 전 | 1245 | ||
| 72 | jQuery Mobile | 8년 전 | 1626 | ||
| 71 | jQuery Mobile | 8년 전 | 1617 | ||
| 70 | jQuery Mobile | 8년 전 | 1500 | ||
| 69 | jQuery Mobile | 8년 전 | 1507 | ||
| 68 | jQuery Mobile | 8년 전 | 2039 | ||
| 67 | jQuery Mobile | 8년 전 | 1313 | ||
| 66 | jQuery Mobile | 8년 전 | 1690 | ||
| 65 | jQuery Mobile | 8년 전 | 1183 | ||
| 64 | jQuery Mobile | 8년 전 | 1465 | ||
| 63 | jQuery Mobile | 8년 전 | 1650 | ||
| 62 | jQuery Mobile | 8년 전 | 1628 | ||
| 61 | jQuery Mobile | 8년 전 | 1873 | ||
| 60 | jQuery Mobile | 8년 전 | 1402 | ||
| 59 | jQuery Mobile | 8년 전 | 1959 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기