[英]Can't upgrade an angular 1.5 component that requires another controller to angular 2
I have two angular 1.5 components: tabs and tab. 我有两个1.5角组件:制表符和制表符。 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. 当我尝试使用UpgradeAdapter将这两个组件升级到angular 2时,TabController的父级始终无法解析,并且出现“未定义没有函数'addTab'”错误消息。
Look like it doesn't understand this.parent. 看起来好像不明白this.parent。 I don't really understand your approach but I would specify child components in parent's template.
我不太了解您的方法,但我会在父级模板中指定子级组件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.