It is used to define an expression that execute when a key is pressed.
Sample coding for ng-keypress directive in AngularJS
Code Explanation for ng-keypress directive in AngularJS:
AngularJS is distributed as a JavaScript file, and can be added to a HTML page with a <script> tag.
The AngularJS application is defined by ng-app=" ". The application runs inside the <body> tag. It’s also used to define a <body> tag as a root element.
The ng-keypress= “count=count+1” is used to increase the count variable by one, every time the key is pressed in the input field.
The ng-init=”count = 0 “ is used to define the initial value of the count variable is “0”.
The {{ count }} is used to dynamically bind the count variable value when the user press the key in the input field.
Sample Output for ng-keypress directive in AngularJS:
The output displays the content “Welcome To Wikitechy” in the text box.
The output shows that the content “The keydown count:20” when the user typed the “Welcome To Wikitechy” in the text box. Here the variable “count” will increase the value by 1, every time a key is pressed in the text box.
Related Searches to angularjs ngKeypress directive
ng keypress enter keyng-keypress keycodeng-keypress on divng-keypress escapeng-keypress backspaceng-keypress preventdefaultangularjs ng-keypressng-keypress not workingangularjs ng-enterangularjs tutorials