首页 > Web开发 > 详细

Angularjs[22] - 内置事件指令

时间:2017-01-31 12:12:21      阅读:223      评论:0      收藏:0      [点我收藏+]
  • 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] - 内置事件指令

原文:http://www.cnblogs.com/bky-1083/p/6358698.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!