AngularJS 이벤트 - ng-click 지시문
AngularJS 이벤트 - ng-click 지시문
이 ng-click 지시자는 요소가 클릭 될 때 실행될 AngularJS 코드를 정의합니다.
예
<div ng-app="myApp" ng-controller="myCtrl">
<button ng-click="count = count + 1">Click me!</button>
<p>{{ count }}</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.count = 0;
});
</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">
<button ng-click="count = count + 1">Click Me!</button>
<p>{{ count }}</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.count = 0;
});
</script>
</body>
</html>
예
<div ng-app="myApp" ng-controller="myCtrl">
<button ng-click="myFunction()">Click me!</button>
<p>{{ count }}</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.count = 0;
$scope.myFunction = function() {
$scope.count++;
}
});
</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">
<button ng-click="myFunction()">Click Me!</button>
<p>{{ count }}</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.count = 0;
$scope.myFunction = function() {
$scope.count++;
}
});
</script>
</body>
</html>
이 ng-click 지시자는 요소가 클릭 될 때 실행될 AngularJS 코드를 정의합니다.
예
<div ng-app="myApp" ng-controller="myCtrl">
<button ng-click="count = count + 1">Click me!</button>
<p>{{ count }}</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.count = 0;
});
</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">
<button ng-click="count = count + 1">Click Me!</button>
<p>{{ count }}</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.count = 0;
});
</script>
</body>
</html>
예
<div ng-app="myApp" ng-controller="myCtrl">
<button ng-click="myFunction()">Click me!</button>
<p>{{ count }}</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.count = 0;
$scope.myFunction = function() {
$scope.count++;
}
});
</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">
<button ng-click="myFunction()">Click Me!</button>
<p>{{ count }}</p>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.count = 0;
$scope.myFunction = function() {
$scope.count++;
}
});
</script>
</body>
</html>
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 208 | 부트스트랩 | 8년 전 | 2737 | ||
| 207 | AngularJS | 8년 전 | 1481 | ||
| 206 | AngularJS | 8년 전 | 1129 | ||
| 205 | AngularJS | 8년 전 | 996 | ||
| 204 | AngularJS | 8년 전 | 1404 | ||
| 203 | AngularJS | 8년 전 | 1199 | ||
| 202 | AngularJS | 8년 전 | 1510 | ||
| 201 | AngularJS | 8년 전 | 1460 | ||
| 200 | AngularJS | 8년 전 | 1436 | ||
| 199 | AngularJS | 8년 전 | 1358 | ||
| 198 | AngularJS | 8년 전 | 1242 | ||
| 197 | AngularJS | 8년 전 | 1402 | ||
| 196 | AngularJS | 8년 전 | 1060 | ||
| 195 | AngularJS | 8년 전 | 1266 | ||
| 194 | AngularJS | 8년 전 | 1278 | ||
| 193 | AngularJS | 8년 전 | 1626 | ||
| 192 | AngularJS | 8년 전 | 1367 | ||
| 191 | AngularJS | 8년 전 | 1594 | ||
| 190 | AngularJS | 8년 전 | 1565 | ||
| 189 | AngularJS | 8년 전 | 1656 | ||
| 188 | AngularJS | 8년 전 | 1415 | ||
| 187 | AngularJS | 8년 전 | 1379 | ||
| 186 | AngularJS | 8년 전 | 1424 | ||
| 185 | AngularJS | 8년 전 | 1453 | ||
| 184 | AngularJS | 8년 전 | 1495 | ||
| 183 | AngularJS | 8년 전 | 1489 | ||
| 182 | AngularJS | 8년 전 | 1018 | ||
| 181 | AngularJS | 8년 전 | 1398 | ||
| 180 | AngularJS | 8년 전 | 1289 | ||
| 179 | AngularJS | 8년 전 | 1270 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기