Javascript ng转移为:元素vs属性
我想创建一个包装器指令,作为列表中通知小部件的框架。在该框架中,我希望稍后基于Javascript ng转移为:元素vs属性,javascript,angularjs,angularjs-directive,transclusion,angularjs-ng-transclude,Javascript,Angularjs,Angularjs Directive,Transclusion,Angularjs Ng Transclude,我想创建一个包装器指令,作为列表中通知小部件的框架。在该框架中,我希望稍后基于notif对象的属性转包一些特定内容。目前我硬编码了一个div元素 index.cshtml中有以下内容: <div ng-controller="notificationCenterCtrl"> <ul> <li ng-repeat="notif in allNotifications"> <notification-base
notif
对象的属性转包一些特定内容。目前我硬编码了一个div
元素
index.cshtml中有以下内容:
<div ng-controller="notificationCenterCtrl">
<ul>
<li ng-repeat="notif in allNotifications">
<notification-base notification="notif" remove="removeNotification(notif)">
<div style="background-color: fuchsia">bla bla</div>
</notification-base>
</li>
</ul>
</div>
为什么下面的工作,即在紫红色背景中显示转置的div
<div>
My notification title: {{notification.name}}
<div ng-transclude id="notificationContent">
</div>
<a ng-click="remove()">Remove</a>
</div>
我的通知标题:{{notification.name}
去除
…但如果我把它当作一种元素使用,紫红色部分就不会再出现了
<div>
My notification title: {{notification.name}}
<div id="notificationContent">
<ng-transclude></ng-transclude>
</div>
<a ng-click="remove()">Remove</a>
</div>
我的通知标题:{{notification.name}
去除
如果我使用ng transclude
作为属性或元素,有什么区别。(我使用Firefox)。直到最近(从这以后)ngTransclude
指令才支持作为元素使用
您可能正在将angular与版本
1.3一起使用,其中ngTransclude
用作元素
不受支持-这是主要原因
<div>
My notification title: {{notification.name}}
<div id="notificationContent">
<ng-transclude></ng-transclude>
</div>
<a ng-click="remove()">Remove</a>
</div>