【问题标题】:Illegal use of ngTransclude directive with UI Router and angular-wizard在 UI 路由器和角度向导中非法使用 ngTransclude 指令
【发布时间】:2014-03-14 06:51:20
【问题描述】:

我在一个带有 UI-router 的项目中使用了 angular-wizard,如果你点击右侧的“创建”按钮,你可以看到一个演示:

http://plnkr.co/edit/XYUamusHru7eV0nvAD5i?p=preview

该向导与当前项目分开工作正常,当我尝试将其集成到我的应用程序时出现问题我在控制台中收到此错误:

Error: [ngTransclude:orphan] Illegal use of ngTransclude directive in the template! No parent directive that requires a transclusion found. Element: <div class="steps" ng-transclude="">

我认为这与 UI-Router 中的模板逻辑有关,或者可能是指令的编写方式创建了“孤儿”。有人对问题所在有任何想法吗?

【问题讨论】:

    标签: javascript angularjs angularjs-directive angular-ui-router


    【解决方案1】:

    看起来你的 NewCampaign.html 正在使用一些复制+粘贴的 dom,因为它有角度 cmets &lt;!-- ngIF ... --&gt;

    清理模板后,您可以看到该模板中没有使用wizard 指令。 wz-step 指令需要在 wizard 指令的上下文中,因为转置发生在 wz-step 内。

    此外,从模板中删除了额外的 ng-app 和 ng-controller。控制器应与状态一起定义。在此处查看固定 plunkr:http://plnkr.co/edit/c3fcV5RSUMXGIFpk8AbV?p=preview

    【讨论】:

    • 这个故事的寓意:对复制面食说不……只有你才能阻止火焰战争。
    • 非常感谢!我现在应该知道直接从 DOM 复制/粘贴不是一个好主意...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-25
    • 2018-02-10
    • 2021-10-01
    相关资源
    最近更新 更多