I have a created a custom web component using angular elements which needs to call a method in main application service.ts.
custom element
@Component({
templateUrl: './sample.component.html',
styleUrls: ['./sample.component.css']
})
export class SampleComponent{
constructor(){
//here i want to call the main application's service method.
}
}
MainApplication.service.ts
@Injectable({
providedIn: 'root'
})
export class StoreService {
getData(): Observable<Model> {
return this.dataSource.asObservable();
}
}
My issue is that i want to call getData() from the custom element. Provided that i have already induced the custom element in MainApplication.component.ts. Emitting some data from custom element to the parent component is easy using eventEmitters and @Output, but when it comes to calling a service method which can provide some data in return, is there any way to do it?