angularjs的事件处理指令测试如下:
今天统一用到的javascript代码如下:
1 var m = angular.module('app', []); 2 m.controller('ctrl', ['$scope', function($scope){ 3 $scope.data = '赵一鸣技术博客'; 4 $scope.func = function(){ 5 alert($scope.data); 6 } 7 }]);
html中的angularjs指令代码:
1、鼠标点击事件:
<input type="text" ng-click="func()"/>
2、鼠标滑过事件:
<input type="text" ng-mouseover="func()"/>
3、鼠标滑出事件:
<input type="text" ng-mouseout="func()"/>
4、鼠标按下事件:
<input type="text" ng-mousedown="func()"/>
5、鼠标抬起事件:
<input type="text" ng-mouseup="func()"/>
6、鼠标双击事件:
<input type="text" ng-dblclick="func()"/>
7、获得焦点事件:
<input type="text" ng-focus="func()"/>
8、失去焦点事件:
<input type="text" ng-blur="func()"/>
9、表单内容改变:
<input type="text" ng-change="func()" ng-model="title"/>
注意,使用ng-change的时候,一定要加ng-model,否则会报错。