首页 > Web开发 > 详细

--@angularJS--简单的带嵌套的指令demo

时间:2015-05-19 18:26:10      阅读:2098      评论:0      收藏:0      [点我收藏+]

<!DOCTYPE HTML>
<html ng-app="app">
<head>
    <title>custom-directive</title>
    <meta charset="utf-8">    
    <link rel="stylesheet" href="../css/bootstrap.css">
    <script src="../js/angular.js"></script>
</head>
<body>
<!-- 下面是带嵌套的自定义指令demo. -->
<div>
    <hello>Lucy</hello>
</div>
<script>
var myModule = angular.module("app",[]);
myModule.directive(‘hello‘,function(){
    return {
        restrict:‘AE‘,
        replace:true,
        transclude:true,
        template:‘<div>Hi there <span ng-transclude></span></div>‘
    }
});//如果声明了模板,而html中还有嵌套内容的话,就必须用<span ng-transclude></span>指定其嵌套的位置,并声明transclude:true,这个属性为true,否则嵌套内容不会显示
</script>
</body>
</html>

--@angularJS--简单的带嵌套的指令demo

原文:http://www.cnblogs.com/koleyang/p/4515074.html

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