I want to use moment.js for displaying the age of a marker shown in google map in my ionic 2 app. I have installed moment.js as
npm install --save angular2-moment
The doc of angular2-moment explains how to use amTimeAgo from template. But I couldn't find anything about using it from type script file. So I decided to try it myself.
First I imported TimeAgo pipe in my app.module.ts and provided it
import { TimeAgoPipe } from "angular2-moment";
...........
providers: [
.............
TimeAgoPipe
]
But when I create a constructor of this TimeAgoPipe as below by importing this file in a component I get the following error.
CODE :
import { TimeAgoPipe } from "angular2-moment";
...........
constructor(private timeAgoPipe: TimeAgoPipe) {}
ERROR :
Uncaught (in promise): Error: No provider for ChangeDetectorRef
You need to add
In module and provide it.