AngularJS 이벤트 - ng-click 지시문

· 8년 전 · 1283
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>
|
댓글을 작성하시려면 로그인이 필요합니다. 로그인

퍼블리싱강좌

+
분류 제목 글쓴이 날짜 조회
AngularJS 8년 전 조회 1,641
AngularJS
[AngularJS]
8년 전 조회 1,395
AngularJS
[AngularJS]
8년 전 조회 1,609
AngularJS 8년 전 조회 1,580
AngularJS
[AngularJS]
8년 전 조회 1,672
AngularJS 8년 전 조회 1,424
AngularJS
[AngularJS]
8년 전 조회 1,388
AngularJS 8년 전 조회 1,416
AngularJS
[AngularJS]
8년 전 조회 1,467
AngularJS
[AngularJS]
8년 전 조회 1,508
AngularJS
[AngularJS]
8년 전 조회 1,498
AngularJS
[AngularJS]
8년 전 조회 1,037
AngularJS
[AngularJS]
8년 전 조회 1,418
AngularJS 8년 전 조회 1,306
AngularJS 8년 전 조회 1,284
AngularJS 8년 전 조회 1,459
AngularJS 8년 전 조회 1,230
AngularJS 8년 전 조회 1,291
AngularJS 8년 전 조회 1,392
AngularJS 8년 전 조회 1,157
AngularJS 8년 전 조회 1,902
AngularJS 8년 전 조회 1,455
AngularJS 8년 전 조회 1,138
AngularJS 8년 전 조회 1,408
AngularJS 8년 전 조회 1,202
AngularJS 8년 전 조회 1,019
AngularJS 8년 전 조회 1,984
AngularJS 8년 전 조회 1,057
AngularJS 8년 전 조회 1,117
AngularJS 8년 전 조회 1,311
🐛 버그신고