How to use TimeAgoPipe of MomentModule from typescript file in angular 2 -


this question has answer here:

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

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -