Reputation: 692
Without import the Angular Service to the module, can we use it?
providers: [ApiService,EmployeeService,DataService,MatDatepickerModule,StudentServiceService
, { provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE] },
{ provide: MAT_DATE_FORMATS, useValue: DateFormats }],
})
here I have imported all the service classes. my question is 'Without import the Angular Service to the module, can we use it?'
Upvotes: 0
Views: 152
Reputation: 12036
with Angular 6 + you can mark services line this
@Injectable({provideIn: 'root'})
class MyService {
...
}
then you dont need to provide them explicitly
Upvotes: 2