angular-cn/public/docs/_examples/cb-dependency-injection/ts/app/app.component.ts

31 lines
844 B
TypeScript
Raw Normal View History

2016-03-26 12:18:13 -04:00
// #docregion
2016-04-27 14:28:22 -04:00
import { Component } from '@angular/core';
2016-03-26 12:18:13 -04:00
// #docregion import-services
import { LoggerService } from './logger.service';
import { UserContextService } from './user-context.service';
import { UserService } from './user.service';
@Component({
moduleId: module.id,
2016-03-26 12:18:13 -04:00
selector: 'my-app',
templateUrl: 'app.component.html',
2016-03-26 12:18:13 -04:00
// #docregion providers
providers: [ LoggerService, UserContextService, UserService ]
2016-03-26 12:18:13 -04:00
// #enddocregion providers
})
export class AppComponent {
// #enddocregion import-services
private userId: number = 1;
2016-03-26 12:18:13 -04:00
// #docregion ctor
constructor(logger: LoggerService, public userContext: UserContextService) {
2016-03-26 12:18:13 -04:00
userContext.loadUser(this.userId);
logger.logInfo('AppComponent initialized');
}
// #enddocregion ctor
// #docregion import-services
}
// #enddocregion import-services