想象一下这样的主机组件代码:呼叫嵌套组件功能angular2
@Component({
directives: [nestedComponentDirective]
})
export class ParentComponent {
save():void {
this.myService.myHTTPCall().subscribe((event) => {
// if callback successfull we need to let directive know
})
}
现在嵌套组件:
@Component({
selector: 'someSelector',
template: `
<div>
<button [stuff]="stuff"</button>
</div>`
})
export class ContinuationCheckDirective {
@Input() waitingForHostedComp(value) {
console.log ("value", value)
}
如何从主机的组件(父)调用waitingForHostedComp?
请提供更多代码。 'save()'和'waitingForHostComp()'在哪里? –
'save()'在ParentComponent中导入ChildComponent。 'waitingForHostComp()'在ChildComponent上。基本上我想要的是当ParentComponent(注入ChildComponent)从服务器获取答案时触发ChildComponent。 – nottinhill