bharat bharat - 1 year ago 141
AngularJS Question

ng-keypress not triggering function

I'm new to AngularJS. I'm implementing ng-keypress events in AngularJS.
I referred to many blogs and tried to do as it is shown, but my code is not working!

<div ng-app="myApp">
<div ng-controller="MainCtrl">
<input ng-keypress="change($event)" type="text" >
{{ text }}

script is:

var myApp = angular.module('myApp', []);

myApp.controller('MainCtrl', ['$scope', function ($scope) {
$scope.text= 'a';

I'm trying to change the value of {{text}} on keypress.. but it's not working!
can anyone help me out!

Thanks :)

Answer Source

i tried the same things and its working

  <body ng-controller="MainCtrl">
    <input  ng-keypress="change($event)" type="text" >

app.controller('MainCtrl', function($scope) {
  $ = 'World';
    $ 'hello';

checkout this plunker... PLUNKER LINK

EDIT checkout your code plunker.. thats also working


finally the answer is: 1.0.7 does not support ng-keypress, hence it was not working..

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download