[AngularJS] Transclude -- using what existing in DOM to replace the template elements in directive

复制代码
var app = angular.module("phoneApp", []);

app.controller("AppCtrl", function($scope) {

});

app.directive("panel", function() {
    return {
        restrict: "E",
        transclude: true,
        template: '<div class="panel" ng-transclude>This is a panel component</div>'
    }
})
复制代码
复制代码
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>Angular Scope &</title>
    <link href="foundation.min.css" rel="stylesheet"/>
    <script src="angular.min.js"></script>
    <script src="app.js"></script>
</head>
<body >
<div ng-app="phoneApp">
    <div ng-controller="AppCtrl">
        <panel>
            <div class="button">Click me!</div>
        </panel>
    </div>
</div>
</body>
</html>
复制代码

posted @   Zhentiw  阅读(261)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示