I am trying to access the data from service,but it can only be accessed if I call one of component function in service function.Is there anything that I can do?
I tried using callback inside observable but that's not working.Is it a good practice to import component inside service and then call a function?
service.ts:
serviceFunc1(){
//I will get some data from here after subscribing
this.serviceFunc2();
CompoFunc1(); // Not able to do
//Calling CompoFunc1() to get items variable(please read entire you'll get it)
}
serviceFunc2(){
//I will use the data that came from serviceFunc1() inside api(loop)
//After subscribing the data I will get some data, that data I will be storing in some variable(assume variable is items)
}
Component.ts:
CompoFunc1(){
//Now I need to acces the variable items inside this component
//So this.service.items;
//But to get items I need to call CompoFunc1() inside serviceFunc1 after serviceFunc2()
}
ngOnInit(){
this.service.serviceFunc1();
}
If any question, feel free to ask.
I just want to access items variable inside component.