Angular2中如何实现日期过滤

How to achieve date filtering in Angular2

我有一个 class,我想在其中使用日期过滤,因为它曾经在 Angular 1:

$filter('date')(startDate, 'yyyy-MM-dd HH:mm:ss')

现在我想使用 Angular 2. 据我所知,我可以使用 DatePipe class。但问题是我不知道如何将它导入我的 class 文件中:

import { Injectable } from '@angular/core'
import { Http, Response, Headers } from '@angular/http';
import { InputValidatorService }  from './input-validator.service';
import { Pipe, PipeTransform } from '@angular/core';

...

myFunctionInsideOfAClass(){
   var datePipe = new DatePipe(); // Symbol 'DatePipe' can not be properly resolved, probably it is located in inaccessible module.
}

我怎样才能做到这一点?

编辑:我的应用模块:

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule }   from '@angular/forms';

..
@NgModule({
    imports: [BrowserModule, FormsModule, HttpModule],
    declarations: [AppComponent, MapComponent, AtileLayerDirective, MapDirective, mapControlDirective, ToolsComponent, SearchComponent],
    bootstrap: [AppComponent],
    providers: [{
        provide: Http,
        useFactory: (_backend: ConnectionBackend, _defaultOptions: RequestOptions) => new HttpInterceptor(_backend, _defaultOptions),
        deps: [XHRBackend, RequestOptions]
    }, mapManager, SearchService, StatusIconProvider
    ]
})
import {DatePipe} from '@angular/common';

@NgModule({
  ...
  providers: [ /* other providers */, DatePipe],
  ...
})