I have two angular 1.5 components: tabs and tab. The tab component requires the controller of tabs component so the latter can manage the active state of the tab components. Here is the code (in typescript):
class TabsComponent implements ng.IComponentOptions {
public bindings: any;
public controller: Function;
constructor() {
this.bindings = {
tabsClass: '@',
onSelect: '&'
};
this.controller = TabsController;
...
}
}
export class TabsController {
...
}
export class TabComponent implements ng.IComponentOptions {
constructor() {
this.require = {
parent: '^TabsComponent'
};
...
}
}
export class TabController {
public $onInit(): void {
this.parent.addTab(this);
};
}
When I tried to upgrade these two components to angular 2 with UpgradeAdapter, the parent in TabController never gets resolved and I get "undefined doesn't have a function 'addTab'" error message.
Look like it doesn't understand this.parent. I don't really understand your approach but I would specify child components in parent's template.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.