0
我使用子路由。我得到了主動路由中的父組件。但是我不知道如何使用它來調用方法。我想要投射組件以便使用它
constructor(public router : Router, public route : ActivatedRoute) { }
ngOnInit() {
let comp = (this.route.parent.component as Type<RegisterComponent>);
console.log(comp);
}
thaniks爲你解答。當我這樣做時,編輯器顯示一個錯誤:type string |類型不能轉換爲類型RegisterComponent。類型''與typr RegisterComponent不具有可比性。爲什麼? –
drtapha