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>
게시판 목록
퍼블리싱강좌
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 178 | AngularJS | 8년 전 | 1436 | ||
| 177 | AngularJS | 8년 전 | 1208 | ||
| 176 | AngularJS | 8년 전 | 1277 | ||
| 175 | AngularJS | 8년 전 | 1373 | ||
| 174 | AngularJS | 8년 전 | 1145 | ||
| 173 | AngularJS | 8년 전 | 1889 | ||
| 172 | AngularJS | 8년 전 | 1440 | ||
| 171 | AngularJS | 8년 전 | 1132 | ||
| 170 | AngularJS | 8년 전 | 1396 | ||
| 169 | AngularJS | 8년 전 | 1191 | ||
| 168 | AngularJS | 8년 전 | 1007 | ||
| 167 | AngularJS | 8년 전 | 1973 | ||
| 166 | AngularJS | 8년 전 | 1045 | ||
| 165 | AngularJS | 8년 전 | 1111 | ||
| 164 | AngularJS | 8년 전 | 1314 | ||
| 163 | AngularJS | 8년 전 | 1158 | ||
| 162 | AngularJS | 8년 전 | 1376 | ||
| 161 | AngularJS | 8년 전 | 1380 | ||
| 160 | AngularJS | 8년 전 | 1137 | ||
| 159 | AngularJS | 8년 전 | 1097 | ||
| 158 | AngularJS | 8년 전 | 1515 | ||
| 157 | AngularJS | 8년 전 | 1483 | ||
| 156 | AngularJS | 8년 전 | 1332 | ||
| 155 | AngularJS | 8년 전 | 1219 | ||
| 154 | AngularJS | 8년 전 | 1626 | ||
| 153 | AngularJS | 8년 전 | 1113 | ||
| 152 | AngularJS | 8년 전 | 1533 | ||
| 151 | AngularJS | 8년 전 | 1431 | ||
| 150 | AngularJS | 8년 전 | 1126 | ||
| 149 | AngularJS | 8년 전 | 1650 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기