Last active
July 18, 2016 06:19
-
-
Save pjlamb12/c3f6633008093eb268fd5b2f618c0934 to your computer and use it in GitHub Desktop.
The child component's output event is called if you call the component's onTestOutputButtonClick() function directly, but if you try and emit an event from inside the service's callback, no event is emitted.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Component Declaration | |
export class ChildComponent { | |
@Output() onOutputEvt: EventEmitter<any> = new EventEmitter<any>(); | |
onTestOutputButtonClick() { | |
this.onOutputEvt.emit({data: 'Emitted data'}); | |
} | |
makeAnUpdate(form) { | |
this._service.makeDbCall(data).subscribe(result => { | |
this.variable = result; | |
this.onOutputEvt.emit({data: 'Emitted data'}); | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<child-component (onOutputEvt)="handleChildOutput($event)"></child-component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Component declaration | |
export class ParentComponent { | |
handleChildOutput(outputData: any) { | |
console.log('I received output from the child component'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment