AngularJS Scope 1
AngularJS Scope
범위는 HTML (보기)와 JavaScript (컨트롤러) 간의 바인딩 부분입니다.
범위는 사용 가능한 속성 및 메서드가있는 객체입니다.
범위는 뷰와 컨트롤러 모두에서 사용할 수 있습니다.
범위 사용 방법
AngularJS에서 컨트롤러를 만들 때 $scope객체를 인수로 전달합니다 .
예
제어기에서 작성된 특성은 뷰에서 참조 할 수 있습니다.
<div ng-app="myApp" ng-controller="myCtrl">
<h1>{{carname}}</h1>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.carname = "Volvo";
});
</script>
$scope 컨트롤러 의 개체에 속성을 추가 하면보기 (HTML)에서 이러한 속성에 액세스 할 수 있습니다.
보기에서, 접두어를 사용하지 않고 $scope, 단지 propertyname을 참조하십시오 {{carname}}.
소스
<!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">
<h1>{{carname}}</h1>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.carname = "Volvo";
});
</script>
<p>The property "carname" was made in the controller, and can be referred to in the view by using the {{ }} brackets.</p>
</body>
</html>
범위는 HTML (보기)와 JavaScript (컨트롤러) 간의 바인딩 부분입니다.
범위는 사용 가능한 속성 및 메서드가있는 객체입니다.
범위는 뷰와 컨트롤러 모두에서 사용할 수 있습니다.
범위 사용 방법
AngularJS에서 컨트롤러를 만들 때 $scope객체를 인수로 전달합니다 .
예
제어기에서 작성된 특성은 뷰에서 참조 할 수 있습니다.
<div ng-app="myApp" ng-controller="myCtrl">
<h1>{{carname}}</h1>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.carname = "Volvo";
});
</script>
$scope 컨트롤러 의 개체에 속성을 추가 하면보기 (HTML)에서 이러한 속성에 액세스 할 수 있습니다.
보기에서, 접두어를 사용하지 않고 $scope, 단지 propertyname을 참조하십시오 {{carname}}.
소스
<!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">
<h1>{{carname}}</h1>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.carname = "Volvo";
});
</script>
<p>The property "carname" was made in the controller, and can be referred to in the view by using the {{ }} brackets.</p>
</body>
</html>
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 118 | jQuery Mobile | 8년 전 | 1333 | ||
| 117 | jQuery Mobile | 8년 전 | 1588 | ||
| 116 | jQuery Mobile | 8년 전 | 1809 | ||
| 115 | jQuery Mobile | 8년 전 | 1772 | ||
| 114 | jQuery Mobile | 8년 전 | 1959 | ||
| 113 | jQuery Mobile | 8년 전 | 1870 | ||
| 112 | jQuery Mobile | 8년 전 | 2479 | ||
| 111 | jQuery Mobile | 8년 전 | 1782 | ||
| 110 | jQuery Mobile | 8년 전 | 1574 | ||
| 109 | jQuery Mobile | 8년 전 | 1733 | ||
| 108 | jQuery Mobile | 8년 전 | 1960 | ||
| 107 | jQuery Mobile | 8년 전 | 1763 | ||
| 106 | jQuery Mobile | 8년 전 | 1443 | ||
| 105 | jQuery Mobile | 8년 전 | 1738 | ||
| 104 | jQuery Mobile | 8년 전 | 2403 | ||
| 103 | jQuery Mobile | 8년 전 | 1552 | ||
| 102 | jQuery Mobile | 8년 전 | 1496 | ||
| 101 | jQuery Mobile | 8년 전 | 1677 | ||
| 100 | jQuery Mobile | 8년 전 | 1912 | ||
| 99 | jQuery Mobile | 8년 전 | 1366 | ||
| 98 | jQuery Mobile | 8년 전 | 1390 | ||
| 97 | jQuery Mobile | 8년 전 | 1648 | ||
| 96 | jQuery Mobile | 8년 전 | 1302 | ||
| 95 | jQuery Mobile | 8년 전 | 1124 | ||
| 94 | jQuery Mobile | 8년 전 | 1519 | ||
| 93 | jQuery Mobile | 8년 전 | 1141 | ||
| 92 | jQuery Mobile | 8년 전 | 1562 | ||
| 91 | jQuery Mobile | 8년 전 | 1509 | ||
| 90 | jQuery Mobile | 8년 전 | 1677 | ||
| 89 | jQuery Mobile | 8년 전 | 1658 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기