如何在 AD 1.0.0 中的 AngularDart 中从其父级引用子组件

编程入门 行业动态 更新时间:2024-10-24 01:51:57
本文介绍了如何在 AD 1.0.0 中的 AngularDart 中从其父级引用子组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我一直在使用这个答案

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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-22 12:02:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1023596.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:其父   组件   如何在   AD   AngularDart

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!