Combine angular2-moment with ionic 2

#1

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

#2

user_challenges.html


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

and i got this error :

#3

Looks like your import is wrong

import {TimeAgoPipe} from 'angular2-moment';
#4

Tried it, didn’t work :confused:

#5

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

#6

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

#7

any suggestions ?i still have problem

#8

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

#9

It works for me just fine

#10

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 ?

#11

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.

#12

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.