Hi everyone,
Why does ionic cli generate Provider and Angular one does generate Service ?
Thanks !
Hi everyone,
Why does ionic cli generate Provider and Angular one does generate Service ?
Thanks !
What do you mean with this sentence?
With Ionic CLI
Command : ionic generate provider test
Class name in result : TestProvider
With Angular CLI
Command : ng g service test
Class name in result : TestService
Kneejerk reply: Because you asked Ionic to create a Provider, and Angular to create a Service…
But you are asking why a Angular “Service” is called “Provider” in Ionic land.
Good question.
My guess: When Ionic went for this naming convention the Angular “best practices” weren’t pinned down yet, and provider was a common name with Ionic1/AngularJS, so they went with that. Maybe also because services are quite often used to provide data to pages in Ionic… but that’s just another wild guess.
They’re really the same thing. Just a name difference.
Thanks @mhartington.
But, like @Sujan12 said previously : Why a Angular “Service” is called “Provider” in Ionic land ?
We went with provider because when you want to include them in your ngModule, they go in the providers array
Can’t answer for Angular, but I’m going to guess it’s because in AngularJS, you have angular.service
, so it makes it may make it easier to understand what it does.
@mhartington, any plans to re-align with Angular ? To me, ionic is an extension of Angular, and I would love to have them perfectly aligned
I think the same, also each time I return to an Ionic project after a long pause I have to rethink again… "is this suppose to be provider or service???
Finally found peace with Providers vs Service in ionic.