NativeScript/nativescript-sdk-examples-ng

http DI example not using root injector

yringler opened this issue · 2 comments

Several times at https://docs.nativescript.org/angular/ng-framework-modules/http, it is made clear that

Note that the services should be explicitly declared in providers

There are other ways to do DI in angular, notably

@Injectable({
  providedIn: 'root',
})
export class MyAwesomeDataService{
  // Service code...
}

or specifying an NgModule in the provided in option.

Are these also ok?
If they are ok, the documentation should be less "opinionated" in tone, and if it's not ok (or just not reccomended) the docs should say why.

@yringler you are absolutely right - using provideIn is another way to declare your service provider. In fact, we are using this approach in our templates (e.g. here).

lock commented

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.