AngularJS Scope 2
AngularJS Scope
범위는 HTML (보기)와 JavaScript (컨트롤러) 간의 바인딩 부분입니다.
범위는 사용 가능한 속성 및 메서드가있는 객체입니다.
범위는 뷰와 컨트롤러 모두에서 사용할 수 있습니다.
범위 이해하기
AngularJS 응용 프로그램을 다음으로 구성한다고 간주 할 경우 :
보기, HTML입니다.
현재보기에 사용할 수있는 데이터 인 모델
Controller : 데이터를 변경 / 제거 / 제어하는 JavaScript 함수입니다.
그런 다음 범위가 모델입니다.
범위는 뷰와 컨트롤러에서 사용할 수있는 속성 및 메서드가있는 JavaScript 객체입니다.
예
뷰를 변경하면 모델과 컨트롤러가 업데이트됩니다.
<div ng-app="myApp" ng-controller="myCtrl">
<input ng-model="name">
<h1>My name is {{name}}</h1>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.name = "John Doe";
});
</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">
<input ng-model="name">
<h1>My name is {{name}}</h1>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.name = "John Doe";
});
</script>
<p>When you change the name in the input field, the changes will affect the model, and it will also affect the name property in the controller.</p>
</body>
</html>
범위는 HTML (보기)와 JavaScript (컨트롤러) 간의 바인딩 부분입니다.
범위는 사용 가능한 속성 및 메서드가있는 객체입니다.
범위는 뷰와 컨트롤러 모두에서 사용할 수 있습니다.
범위 이해하기
AngularJS 응용 프로그램을 다음으로 구성한다고 간주 할 경우 :
보기, HTML입니다.
현재보기에 사용할 수있는 데이터 인 모델
Controller : 데이터를 변경 / 제거 / 제어하는 JavaScript 함수입니다.
그런 다음 범위가 모델입니다.
범위는 뷰와 컨트롤러에서 사용할 수있는 속성 및 메서드가있는 JavaScript 객체입니다.
예
뷰를 변경하면 모델과 컨트롤러가 업데이트됩니다.
<div ng-app="myApp" ng-controller="myCtrl">
<input ng-model="name">
<h1>My name is {{name}}</h1>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.name = "John Doe";
});
</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">
<input ng-model="name">
<h1>My name is {{name}}</h1>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.name = "John Doe";
});
</script>
<p>When you change the name in the input field, the changes will affect the model, and it will also affect the name property in the controller.</p>
</body>
</html>
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 148 | AngularJS | 8년 전 | 1655 | ||
| 147 | AngularJS | 8년 전 | 1073 | ||
| 146 | AngularJS | 8년 전 | 1260 | ||
| 145 | AngularJS | 8년 전 | 1370 | ||
| 144 | AngularJS | 8년 전 | 1155 | ||
| 143 | AngularJS | 8년 전 | 1201 | ||
| 142 | AngularJS | 8년 전 | 1171 | ||
| 141 | AngularJS | 8년 전 | 1335 | ||
| 140 | AngularJS | 8년 전 | 1197 | ||
| 139 | AngularJS | 8년 전 | 1440 | ||
| 138 | AngularJS | 8년 전 | 1151 | ||
| 137 | AngularJS | 8년 전 | 1062 | ||
| 136 | AngularJS | 8년 전 | 1152 | ||
| 135 | AngularJS | 8년 전 | 1677 | ||
| 134 | AngularJS | 8년 전 | 1380 | ||
| 133 | AngularJS | 8년 전 | 1475 | ||
| 132 | AngularJS | 8년 전 | 1098 | ||
| 131 | AngularJS | 8년 전 | 1370 | ||
| 130 | AngularJS | 8년 전 | 1465 | ||
| 129 | AngularJS | 8년 전 | 1442 | ||
| 128 | AngularJS | 8년 전 | 2061 | ||
| 127 | AngularJS | 8년 전 | 1484 | ||
| 126 | jQuery Mobile | 8년 전 | 2259 | ||
| 125 | jQuery Mobile | 8년 전 | 2015 | ||
| 124 | jQuery Mobile | 8년 전 | 1882 | ||
| 123 | jQuery Mobile | 8년 전 | 1813 | ||
| 122 | jQuery Mobile | 8년 전 | 1854 | ||
| 121 | jQuery Mobile | 8년 전 | 2059 | ||
| 120 | jQuery Mobile | 8년 전 | 1593 | ||
| 119 | jQuery Mobile | 8년 전 | 1678 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기