export class ComponentB { functionToBeCalledInB(): void{ } } export class ComponentA implement OnInit { // how to reference componentB in a function of ComponentA? frameworkComponents:any={ componentB:ComponentB, } functionInAToCallB(){ // here, what should be the correct syntax? I am new to typescript // I have tried these ways, but no success this.frameworkComponents.componentB.functionToBeCalledInB(); this.frameworkComponents.ComponentB.functionToBeCalledInB(); } }
多谢,有从属关系的,A里面有B component.
export class ComponentA implement OnInit { // 多谢。请问这个frameworkComponents 是什么类型?是一个array还是一个anonymous class? frameworkComponents:any={ componentB:ComponentB, }