加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular 练习

发布时间:2020-12-17 09:59:18 所属栏目:安全 来源:网络整理
导读:!DOCTYPE htmlhtmlhead lang="en" meta charset="UTF-8" script src="framework/1.3.0.14/angular.js"/script script src="framework/1.3.0.14/angular-route.js"/script script src="framework/1.3.0.14/angular-animate.js"/script script src="js/test2.j



<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <script src="framework/1.3.0.14/angular.js"></script>
    <script src="framework/1.3.0.14/angular-route.js"></script>
    <script src="framework/1.3.0.14/angular-animate.js"></script>
    <script src="js/test2.js"></script>
    <script src="js/controllers.js"></script>
    <script src="js/filters.js"></script>
    <script src="js/services.js"></script>
    <script src="js/directives.js"></script>
    <title>练习</title>
</head>
<body>
    <div ng-app="app">
        <hello></hello>
        <div attrDire class="classDire"></div>
        <div ng-controller="AppCtrl">
            <div enter="loadMoreData">I me here.</div>
        </div>
    </div>
</body>
</html>

/**
 * Created by dell on 2016/9/6.
 */

var app=angular.module('app',[]);

app.directive('hello',function(){
    return {
        restrict:'E',replace:true,template:'<div>hello liaojianguo</div>'
    }
})

app.directive('attrDire',function(){
    return {
        restrict:'A',link:function(){
            alert("我是属性");
        }
    }
})

app.directive('classDire',function(){
    return {
        restrict:'C',link:function(){
            alert("我是class");
        }
    }
})

app.controller('AppCtrl',function($scope){
    $scope.loadMoreData=function(){
        alert("正在加载数据中......");
    }
})

app.directive('enter',function(){
    return function(scope,element,attrs)
    {
        element.bind('mouseenter',function(){
            scope.$apply(attrs.enter);
        });
    }
})

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读