问题
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