That was helpful ! If I understand well, Angular 7 merged services and providers into services. Right ? Should we do one service for all API requests or slice it into multiple services ?
Is there such a thing as too many services? Should I try to keep the number resonably low with long services or is it best practice to have many small ones? I can see arguments for both.
In the end, I think it comes down to what works best for your application. Generally, I would have a separate provider for each entity/concept in the application (Users, Todos, Jobs, etc).
nice vdo man ! I have this function in the service file printArray() { const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; console.log(arr); } & I'm calling this function in home.page.ts as following: import { AdServiceService } from '../ad-service.service'; constructor(adService: AdServiceService) { } printValue() { this.adService.printArray().subscribe((resp) => { console.log(resp); }) } but geting error under "adService" inside printValue() function can you suggest me any solution for this issue thanks in advance!!!!!!
you can simply do these following steps: in your service page (let's say "example.service.ts) declare a variable userData = { "param1" : " ", "param2" : "" }; , in the page you want to use it -> import { ExampleService} from '../services/example.service'; and in the constructor declare it as constructor(private myService : ExampleService) {} - for using it just type this.myService.userData.param1 = "test"; this.myService.userData.param2 = "test for parameter 2" etc