docs: update examples for tree-shakeable providers (#22961)
PR Close #22961
This commit is contained in:
@ -6,7 +6,6 @@ import { UserService } from './user.service';
|
||||
|
||||
@NgModule({
|
||||
imports: [ BrowserModule ],
|
||||
providers: [ UserService ],
|
||||
declarations: [ AppComponent ],
|
||||
bootstrap: [ AppComponent ]
|
||||
})
|
||||
|
9
aio/content/examples/providers/src/app/user.module.ts
Normal file
9
aio/content/examples/providers/src/app/user.module.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
|
||||
import { UserService } from './user.service';
|
||||
|
||||
@NgModule({
|
||||
providers: [UserService],
|
||||
})
|
||||
export class UserModule {
|
||||
}
|
7
aio/content/examples/providers/src/app/user.service.0.ts
Normal file
7
aio/content/examples/providers/src/app/user.service.0.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class UserService {
|
||||
}
|
8
aio/content/examples/providers/src/app/user.service.1.ts
Normal file
8
aio/content/examples/providers/src/app/user.service.1.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { UserModule } from './user.module';
|
||||
|
||||
@Injectable({
|
||||
providedIn: UserModule,
|
||||
})
|
||||
export class UserService {
|
||||
}
|
@ -3,9 +3,7 @@ import { UserService } from './user.service';
|
||||
|
||||
describe('UserService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [UserService]
|
||||
});
|
||||
TestBed.configureTestingModule({});
|
||||
});
|
||||
|
||||
it('should ...', inject([UserService], (service: UserService) => {
|
||||
|
@ -5,7 +5,9 @@ export class User {
|
||||
name: string;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class UserService {
|
||||
|
||||
constructor() { }
|
||||
|
Reference in New Issue
Block a user