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년 전 | 2746 | ||
| 207 | AngularJS | 8년 전 | 1494 | ||
| 206 | AngularJS | 8년 전 | 1139 | ||
| 205 | AngularJS | 8년 전 | 1006 | ||
| 204 | AngularJS | 8년 전 | 1414 | ||
| 203 | AngularJS | 8년 전 | 1212 | ||
| 202 | AngularJS | 8년 전 | 1524 | ||
| 201 | AngularJS | 8년 전 | 1471 | ||
| 200 | AngularJS | 8년 전 | 1444 | ||
| 199 | AngularJS | 8년 전 | 1367 | ||
| 198 | AngularJS | 8년 전 | 1249 | ||
| 197 | AngularJS | 8년 전 | 1412 | ||
| 196 | AngularJS | 8년 전 | 1075 | ||
| 195 | AngularJS | 8년 전 | 1275 | ||
| 194 | AngularJS | 8년 전 | 1291 | ||
| 193 | AngularJS | 8년 전 | 1637 | ||
| 192 | AngularJS | 8년 전 | 1374 | ||
| 191 | AngularJS | 8년 전 | 1602 | ||
| 190 | AngularJS | 8년 전 | 1575 | ||
| 189 | AngularJS | 8년 전 | 1665 | ||
| 188 | AngularJS | 8년 전 | 1424 | ||
| 187 | AngularJS | 8년 전 | 1388 | ||
| 186 | AngularJS | 8년 전 | 1432 | ||
| 185 | AngularJS | 8년 전 | 1464 | ||
| 184 | AngularJS | 8년 전 | 1505 | ||
| 183 | AngularJS | 8년 전 | 1499 | ||
| 182 | AngularJS | 8년 전 | 1030 | ||
| 181 | AngularJS | 8년 전 | 1409 | ||
| 180 | AngularJS | 8년 전 | 1299 | ||
| 179 | AngularJS | 8년 전 | 1284 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기