I am new to Angular 8 and I have encountered an issue with it.
In my project, I have two components: the discussion component
and the topic component
.
Within the discussion component, there is a sub-component called the add-files component
,
and within the topic component, there is a sub-component known as the add-topic component
.
My goal is to set up an observable in the add-files component that will trigger whenever a button in the add-topic component is clicked.
Below is how I attempted to achieve this:
add-files.component.ts
@Input()
fileEventsAdd: Observable<void>;
private fileEventsSubscriptionTopic: Subscription;
ngOnInit() {
this.fileEventsSubscriptionTopic = this.fileEventsAdd.subscribe(
()=> this.uploader.clearQueue()
);
}
Now, the observable created in the add-files.component.ts needs to be accessed from the add-topic component
(which is a sub-component of the topic component
), but I'm uncertain about the correct approach for this.
The topic and discussion components are at the same level, while the add-files component is nested within the discussion component
and the add-topic
component is a sub-component of the topic component
.
Could someone provide guidance on how to accomplish this?