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

angularJS指令模板替换

时间:2015-05-10 11:14:39      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:

<html>
<head>
    <meta charset="utf-8"/>
    <title></title>
</head>
<body ng-app="components">
<myelement>
    <h1>哈哈</h1>
</myelement>
</body>
<script src="angular.js"></script>
<script>
    var app= angular.module(‘components‘, []);
    app.directive(‘myelement‘, function() {
        return {
            restrict: ‘AE‘,//自定义属性和Dom节点
            transclude: true,//将自定义指令内部原有的节点保留(这里注意,自定义指令中的内容在模板中必须有父节点)
            scope: {},
            templateUrl:"templates/templateOther.html",
            replace: true//全部替换
        };
    });
</script>
</html>

  

angularJS指令模板替换

标签:

原文地址:http://www.cnblogs.com/zzq-include/p/4491898.html

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