angular 练习

前端之家收集整理的这篇文章主要介绍了angular 练习前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。



<!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);
        });
    }
})
原文链接:https://www.f2er.com/angularjs/148952.html

猜你在找的Angularjs相关文章