• Angularjs 事件指令


    1.  点击事件

    <!DOCTYPE html>
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>无标题文档</title>
        <script type="text/javascript" src="angular.min.js"></script>
    </head>
    <body>
    <div ng-app="myApp">
    
        <div ng-controller="firstController">
            <div ng-click="run()">点击</div>
        </div>
    </div>
    <script type="text/javascript">
        var app = angular.module("myApp", []);
        app.controller('firstController',function($scope){
            $scope.text='phonegap中文网';
    
            $scope.run=function(){
    
                alert('run');
                console.log('run');
            }
        });
    </script>
    
    </body>
    </html>
    

      

    2. 样式 ng-class

    <!DOCTYPE html>
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>无标题文档</title>
        <script type="text/javascript" src="angular.min.js"></script>
        <style>
            .red{background:red;}
            .yellow{background:yellow;}
        </style>
    </head>
    <body>
    <div ng-app="myApp">
    
        <div ng-controller="firstController">
            <div ng-click="run()">点击</div>
            <div ng-class="{red:true}">{{text}}</div>
        </div>
    </div>
    <script type="text/javascript">
        var app = angular.module("myApp", []);
        app.controller('firstController',function($scope){
            $scope.text='phonegap中文网';
    
            $scope.run=function(){
    
                alert('run');
                console.log('run');
            }
        });
    </script>
    
    </body>
    </html>
    

      

  • 相关阅读:
    洛谷 U141580 简化罗波切问题
    洛谷 U141578 维修电路
    洛谷 U140760 狭义公因子
    CF75C Modified GCD
    算法题-求解斐波那切数列的第N个数是几?
    算法题-求N的阶乘
    JAVA8新特性
    nginx启动脚本,手动编辑
    javah生成带有包名的头文件
    Matlab图像处理(03)-基本概念
  • 原文地址:https://www.cnblogs.com/linlf03/p/7137758.html
Copyright © 2020-2023  润新知