Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ng转移为:元素vs属性_Javascript_Angularjs_Angularjs Directive_Transclusion_Angularjs Ng Transclude - Fatal编程技术网

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>