如何在AD 1.0.0中的AngularDart中从其父级引用子级组件 [英] How to reference child component from its parent in AngularDart in AD 1.0.0

查看:102
本文介绍了如何在AD 1.0.0中的AngularDart中从其父级引用子级组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在用这个答案

AngularDart:如何在自定义中包含子组件组件模板

使用与此类似的内容:

<tabs>
  <tab>some tab content</tab>
  <tab>another tab</tab>
</tabs>

我的Tab构造函数就像

My constructor for Tab is like

Tab(Tabs tabs) {
   tabs.add(this);
}

这将允许我创建一个制表符"组件,并将子项制表符"添加到选项卡"控制器中的选项卡列表中.

This would let me create a "Tabs" component and add the child "Tab" to the a list of tabs in the the Tabs controller.

直到AngularDart 0.14.0,但使用1.0时,传递给子级构造函数的组件现在为null,无法添加到父级.

Up until AngularDart 0.14.0, but with 1.0 the component passed to the constructor of the child is now null and cannot be added to the parent.

有人知道现在如何在AngularDart 1.0.0中实现相同的目标吗?

Anyone know how to now achieve the same in AngularDart 1.0.0?

推荐答案

好吧,事实证明,问题更多地与注入的范围有关,还有控制器"现在是组件"这一事实,这意味着您必须设置templateUrl或模板html来呈现内容.

OK it turns out that the issue was more around the Scope being injected and also the fact that "Controllers" are now "Components", which means you have to set the templateUrl, or template html to render the content.

仅用组件替换Controller无效,您需要将所有html代码移至模板文件.

Simply replacing Controller with a Component wont work you need to shift all the html code to a template file.

这篇关于如何在AD 1.0.0中的AngularDart中从其父级引用子级组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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