angular-cn/public/docs/_examples/cb-dependency-injection/ts/app/date-logger.service.ts

39 lines
1.1 KiB
TypeScript
Raw Normal View History

2016-03-26 12:18:13 -04:00
/* tslint:disable:one-line:check-open-brace*/
// #docregion
2016-04-27 14:28:22 -04:00
import { Injectable } from '@angular/core';
2016-03-26 12:18:13 -04:00
import { LoggerService } from './logger.service';
// #docregion minimal-logger
// class used as a restricting interface (hides other public members)
export abstract class MinimalLogger {
logInfo: (msg: string) => void;
logs: string[];
}
// #enddocregion minimal-logger
/*
// Transpiles to:
// #docregion minimal-logger-transpiled
var MinimalLogger = (function () {
function MinimalLogger() {}
return MinimalLogger;
}());
exports("MinimalLogger", MinimalLogger);
// #enddocregion minimal-logger-transpiled
*/
// #docregion date-logger-service
@Injectable()
// #docregion date-logger-service-signature
export class DateLoggerService extends LoggerService implements MinimalLogger
// #enddocregion date-logger-service-signature
{
logInfo(msg: any) { super.logInfo(stamp(msg)); }
logDebug(msg: any) { super.logInfo(stamp(msg)); }
logError(msg: any) { super.logError(stamp(msg)); }
}
function stamp(msg: any) { return msg + ' at ' + new Date(); }
// #enddocregion date-logger-service