How to use TimeAgoPipe of MomentModule from typescript file in angular 2 -
this question has answer here:
- angular2-moment pipe in javascript 1 answer
i want use moment.js displaying age of marker shown in google map in ionic 2 app. have installed moment.js
npm install --save angular2-moment
the doc of angular2-moment explains how use amtimeago template. couldn't find using type script file. decided try myself.
first imported timeago pipe in app.module.ts , provided it
import { timeagopipe } "angular2-moment"; ........... providers: [ ............. timeagopipe ]
but when create constructor of timeagopipe below importing file in component following error.
code :
import { timeagopipe } "angular2-moment"; ........... constructor(private timeagopipe: timeagopipe) {}
error :
uncaught (in promise): error: no provider changedetectorref
you need add
import { changedetectorref } '@angular/core';
in module , provide it.
Comments
Post a Comment