AngularJs directive-transclude

来源:互联网 发布:sunny crown 人工智能 编辑:程序博客网 时间:2024/06/05 08:31

transclude制定是否复用标签内部的html

制定方式是将当前标签内部内容,复制一份到template中制定 ng-transclude的元素内部

1.代码:

<body ng-app="myApp">    <my-site>        <p class="text-danger">原始的内容</p>    </my-site></body>
//transclude 是否复制原来控件内容,到 ng-transclude 的元素内部var app = angular.module('myApp', []);app.directive('mySite', function () {    return {        restrict: 'E',        template: '<strong>重点内容</strong><div ng-transclude></div>',        transclude: true    };});


0 0
原创粉丝点击