After creating a sample of all the Angular Js events, I noticed that when the page is initially loaded, the default value of the model textbox is always showing as 11. I am curious to understand why this default value is set to 11.
Here is an excerpt from my HTML code: Examples on Click events
<input ng-blur="blur=blur+1" />
Blur Events : {{blur}}<br/>
<input ng-click="click=click+1" />
Click Events : {{click}}<br/>
<input ng-dblclick="dblclick=dblclick+1" />
Double click Events : {{dblclick}}<br/>
<input ng-copy="copy=copy+1" />
Copy Events : {{copy}}<br/>
<input ng-paste="paste=paste+1" />
Paste Events : {{paste}}<br/>
<input ng-cut="cut=cut+1" />
Cut Events : {{cut}}<br/>
<input ng-focus="focus=focus+1" />
Focus Events : {{focus}}<br/>
<input ng-model="model1=model1+1" />
Model Events : {{model1}}<br/>
<input ng-change="change=change+1" />
Change Events : {{change}}<br/>
<input ng-keydown="keydown($event)" />
Keydown Events : {{kdkey}}<br/>
<input ng-mouseenter="mouseenter=mouseenter+1" />
Mouseenter Events : {{mouseenter}}<br/>
<input ng-mouseleave="mouseleave=mouseleave+1" />
Mouseleave Events : {{mouseleave}}<br/>
</div>
</body>
</html>
My Javascript code snippet appears as follows:
var app5 = angular.module('MyApp5', []);
app5.controller('eventCtrl', function ($scope) {
$scope.blur = 0;
$scope.click = 0;
$scope.dblclick = 0;
$scope.copy = 0;
$scope.paste = 0;
$scope.cut = 0;
$scope.model = 0;
$scope.change = 0;
$scope.mouseenter = 0;
$scope.mouseleave = 0;
$scope.keydown = function(e) {
$scope.kdkey = String.fromCharCode(e.keyCode);
};
});
I am wondering if the reason the default value for model
is set to 11 could be related to it being a directive (ng-model
) and possibly interacting with other event directives?
Despite changing the values and trying different approaches such as using model1
, I still find that the default value remains at 11. Any insights on this behavior would be greatly appreciated.
EDIT
You can also view a similar example on JSFiddle: here.
I have not been able to successfully resolve this issue. If you have any suggestions or solutions, please share them with me.