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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -