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>
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 58 | jQuery Mobile | 8년 전 | 2989 | ||
| 57 | jQuery Mobile | 8년 전 | 2034 | ||
| 56 | jQuery Mobile | 8년 전 | 1369 | ||
| 55 | jQuery Mobile | 8년 전 | 1562 | ||
| 54 | jQuery Mobile | 8년 전 | 2245 | ||
| 53 | jQuery Mobile | 8년 전 | 1546 | ||
| 52 | jQuery Mobile | 8년 전 | 1563 | ||
| 51 | jQuery Mobile | 8년 전 | 1429 | ||
| 50 | jQuery Mobile | 8년 전 | 1320 | ||
| 49 | jQuery Mobile | 8년 전 | 1820 | ||
| 48 | jQuery Mobile | 8년 전 | 1463 | ||
| 47 | jQuery Mobile | 8년 전 | 2022 | ||
| 46 | jQuery Mobile | 8년 전 | 1982 | ||
| 45 | jQuery Mobile | 8년 전 | 1514 | ||
| 44 | jQuery Mobile | 8년 전 | 1679 | ||
| 43 | jQuery Mobile | 8년 전 | 1793 | ||
| 42 | jQuery Mobile | 8년 전 | 1668 | ||
| 41 | jQuery Mobile | 8년 전 | 1836 | ||
| 40 | jQuery Mobile | 8년 전 | 1488 | ||
| 39 | jQuery Mobile | 8년 전 | 1639 | ||
| 38 | jQuery Mobile | 8년 전 | 2183 | ||
| 37 | jQuery Mobile | 8년 전 | 2685 | ||
| 36 | jQuery Mobile | 8년 전 | 2140 | ||
| 35 | jQuery Mobile | 8년 전 | 1528 | ||
| 34 | jQuery Mobile | 8년 전 | 2430 | ||
| 33 | AngularJS | 8년 전 | 2881 | ||
| 32 | AngularJS | 8년 전 | 2442 | ||
| 31 | AngularJS | 8년 전 | 1769 | ||
| 30 | AngularJS | 8년 전 | 2848 | ||
| 29 | AngularJS | 8년 전 | 2406 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기