ellar icon indicating copy to clipboard operation
ellar copied to clipboard

simplify the method of using provider

Open ockan opened this issue 1 year ago • 1 comments

Now,to realize the provider,3 steps needed:

1\declare the injectable service: image

2\give it as a argument of AppFactory: image

3\use really the provider: image

that is complex.why need to use the decorator '@injectable'? why need to register provider to AppFactory?it is confused.

ockan avatar Dec 06 '24 12:12 ockan

@ockan @Injectable is used to define the lifetime scope of the provider object. If you don't use @Injectable, and you register the service on the AppFactory or Module the application will assume the provider as a singleton scope. Also, providers in AppFactory or `Module' are registered in the Ellar DI container making them available for injection.

But @ockan, if you feel there are other ways this could be made easy, please share, I would love to hear your suggestion.

eadwinCode avatar Dec 08 '24 21:12 eadwinCode