指令,孤立范围,继承

时间:2014-03-11 09:40:23

标签: angularjs angularjs-directive angularjs-scope

我完全被这些主题搞糊涂了,真的需要一只手来生存。非常感谢提前。

<xxx:layout style="height: 100px; width: 100%" xxx-horizontal>
    <xxx:layout style="width: 150px; background: yellow">I need to know my parent's orientation (should be horizontal:{{orientation}})</xxx:layout>
    <xxx:layout style="width: 450px; background: green">I need to know my parent's orientation (should be horizontal:{{orientation}})</xxx:layout>
    <xxx:layout style="width: 200px" xxx-vertical>
        <xxx:layout style="background: red; height: 50%">I need to know my parent's orientation (should be vertical:{{orientation}})</xxx:layout>
        <xxx:layout style="background: cyan; height: 50%">I need to know my parent's orientation (should be vertical:{{orientation}})</xxx:layout>
    </xxx:layout>
</xxx:layout>

简单地说,我需要知道子链接函数中父类的属性(由xxx-vertical或xxx-horizo​​ntal A-directive管理)。这个Plunk描述了当前的“成功”。

1 个答案:

答案 0 :(得分:0)

这可以做你想要的,但是它没有使用那个布局指令,我不知道你是否真的需要它,因为我不知道你的指令的目的,但你不应该使用transclude当你其中有其他指令。

plnkr