docs: update examples for tree-shakeable providers (#22961)

PR Close #22961
This commit is contained in:
Alex Rickabaugh
2018-03-23 08:36:48 -07:00
parent ed53c5ccdd
commit e1ea7ed019
25 changed files with 154 additions and 13 deletions

View File

@ -6,7 +6,6 @@ import { UserService } from './user.service';
@NgModule({
imports: [ BrowserModule ],
providers: [ UserService ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})

View File

@ -0,0 +1,9 @@
import { NgModule } from '@angular/core';
import { UserService } from './user.service';
@NgModule({
providers: [UserService],
})
export class UserModule {
}

View File

@ -0,0 +1,7 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root',
})
export class UserService {
}

View File

@ -0,0 +1,8 @@
import { Injectable } from '@angular/core';
import { UserModule } from './user.module';
@Injectable({
providedIn: UserModule,
})
export class UserService {
}

View File

@ -3,9 +3,7 @@ import { UserService } from './user.service';
describe('UserService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [UserService]
});
TestBed.configureTestingModule({});
});
it('should ...', inject([UserService], (service: UserService) => {

View File

@ -5,7 +5,9 @@ export class User {
name: string;
}
@Injectable()
@Injectable({
providedIn: 'root',
})
export class UserService {
constructor() { }