「AngularJS」ng-keypressディレクティブを使うサンプル

2020年12月5日

構文
<element ng-keypress="expression"></element>
サポート:<input>, <select>, <textarea>
使用例
htmlコード

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<head>
<meta charset="utf-8">
<script src="/angular.js/1.4.6/angular.min.js"></script>
</head>
<head> <meta charset="utf-8"> <script src="/angular.js/1.4.6/angular.min.js"></script> </head>
<head>
<meta charset="utf-8">
<script src="/angular.js/1.4.6/angular.min.js"></script>
</head>

JSコード

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<body ng-app="">
<input ng-keypress="cnt = cnt + 1" ng-init="cnt=0" />
<h1>{{cnt}}</h1>
<p>input textbox keypress,parameter cnt will add 1</p>
<body ng-app=""> <input ng-keypress="cnt = cnt + 1" ng-init="cnt=0" /> <h1>{{cnt}}</h1> <p>input textbox keypress,parameter cnt will add 1</p>
<body ng-app="">
<input ng-keypress="cnt = cnt + 1" ng-init="cnt=0" />

<h1>{{cnt}}</h1>

<p>input textbox keypress,parameter cnt will add 1</p>

 

AngularJS

Posted by arkgame