How to reference child component from its parent in AngularDart in AD 1.0.0

房东的猫 提交于 2019-12-11 03:07:32

问题


I have been using the answer from this

AngularDart: How to include subcomponents in a custom component template

Using something similar to this:

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

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.

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.

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


回答1:


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.

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



来源:https://stackoverflow.com/questions/26764718/how-to-reference-child-component-from-its-parent-in-angulardart-in-ad-1-0-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!