I want to use the datePipe in my component. I followed the instructions [here](https://stackoverflow.com/questions/35144821/angular-2-4-use-pipes-in-services-and-components) but I am met with

```none
Error: StaticInjectorError[DatePipe]: 
StaticInjectorError[DatePipe]: 
NullInjectorError: No provider for DatePipe!

```

Here is my code:

**Component**

```js
import { DatePipe } from '@angular/common';

export class LivePreviewComponent implements OnInit{
    currentDate = new Date();     

    constructor(private datePipe:DatePipe) {}
    ngOnInit() {
        this.datePipe.transform(this.currentDate, 'YYYY-MM-DDTHH:mm')
    }
}

```