我怎样包括在角我的客户指令的模板其他指令? [英] How do I include other directives in the template of my customer directive in Angular?

查看:81
本文介绍了我怎样包括在角我的客户指令的模板其他指令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个简单的自定义指令。在模板的本指令中还包括其他指令(例如 UI可排序)。因为它没有的总是的使用ui可排序,我在链接阶段添加。然而,它似乎并不适用:

I wrote a simple custom directive. The template in this directive includes other directives (e.g. ui-sortable). Because it doesn't always use ui-sortable, I add it in the link phase. Yet it doesn't seem to apply:

        link: function ($scope,$element,attrs) {
attrs.$observe('admin', function(value) {
  if ($scope.admin) {
        $element.find("span").html("true");
      $element.find("ul").attr("ui:sortable","sortableOptions");
  }
});
    }

全部小提琴例子是在这里: http://jsfiddle.net/VjfEf/4/

有两个列表。第一次使用 UI可排序直接拖动/删除/排序工作,第二个使用我的自定义成员指令。该指令不工作,它呈现,但增加的 UI可排序作为第一个没有任何影响和拖/放完全相同的方式/排序没有。

There are two lists. The first uses ui-sortable directly and drag/drop/sort works, the second uses my custom members directive. The directive does work, it renders, but the addition of ui-sortable in the exact same way as the first has no impact and drag/drop/sort does not.

我假设我不理解的东西有关自定义指令的处理阶段,并要么需要添加一些我的自定义指令?

I am assuming I am not understanding something about the processing phases of custom directives, and either need to add something to my custom directive?

推荐答案

您需要编译新添加的HTML。

You need to compile the newly added HTML.

$compile($element.contents())($scope);

<大骨节病> 小提琴

这篇关于我怎样包括在角我的客户指令的模板其他指令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆