Angularjs[22] - 内置事件指令
Posted 。娴
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Angularjs[22] - 内置事件指令相关的知识,希望对你有一定的参考价值。
- ng-change
- ng-click
- ng-dbclick
- ng-mousedown
- ng-mouseenter
- ng-mouseleave
- ng-mousemove
- mg-mouseover
- ng-mouseup
- ng-submit
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> </head> <body> <div ng-app="myApp"> <div ng-controller="firstController"> <button ng-click="changeStatus($event)">切换状态</button> {{status}} </div> </div> <script type="text/javascript" src="../../vendor/angular/angularjs.js"></script> <script type="text/javascript" src="app/index.js"></script> </body> </html>
var myApp = angular.module(\'myApp\',[]) .controller(\'firstController\',function ($scope) { $scope.status = \'false\'; // $scope.changeStatus = function () { // $scope.status = !$scope.status; // } $scope.changeStatus = function (event) { //通过 element 转换成 jquery 对象 angular.element(event.target).html(\'转换状态为:\' + $scope.status); $scope.status = !$scope.status; } });
以上是关于Angularjs[22] - 内置事件指令的主要内容,如果未能解决你的问题,请参考以下文章
AngularJS – 如何在 Jasmine 中为输入事件指令编写单元测试
将 keydown 事件定位到 angularJS 自定义指令