码迷,mamicode.com
首页 > Web开发 > 详细

Angularjs[22] - 内置事件指令

时间:2017-01-31 12:14:37      阅读:275      评论:0      收藏:0      [点我收藏+]

标签:color   angularjs   []   分享   use   over   span   $scope   html   

  • 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] - 内置事件指令

标签:color   angularjs   []   分享   use   over   span   $scope   html   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!