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

查看:24
本文介绍了如何在 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天全站免登陆