Combine angular2-moment with ionic 2

how can i combine angular2-moment from https://github.com/urish/angular2-moment/
with my ionic 2 App

image

user_challenges.html


<time>{{post.challenge_start | amTimeAgo }}</time>

and i got this error :

Looks like your import is wrong

import {TimeAgoPipe} from 'angular2-moment';

Tried it, didn’t work :confused:

I did like you. But, for me worked.

import {TimeAgoPipe} from 'angular2-moment/TimeAgoPipe.js';
@Component({
    ...,
    pipes: [TimeAgoPipe],
    ...
})

In my HTML:

{{lastSync | amTimeAgo}}

Did you installed angular2-moment? npm install angular2-moment

Yes i’m already installed and still got the same error : “Error: Template parse errors: The pipe ‘amTimeAgo’ could not be found”

any suggestions ?i still have problem

I’m having the same exact issue. I’m clueless.

It works for me just fine

did you find a solution ?
I get the same error : The pipe ‘amTimeAgo’ could not be found

I installed using these :
>npm install --save angular2-moment
then in app.module.ts

import { MomentModule } from 'angular2-moment';
  imports: [
    (...)
    MomentModule

Can you help me ?

For those still having problems…

The documentation doesn’t account for LazyLoading. If you’re LazyLoading your pages… you can try adding the import { MomentModule } from ‘ngx-moment’; to your page.module.ts.

Have you inspected the resulting binary? When lazy loading first came out, doing this would result in having N copies of moment (which itself is ginormous), one for each lazily loaded page that incorporated it. I don’t know if things have improved on this front since then.