Open Famin42 opened 4 years ago
Same problem with Angular 9.
@AndrewPoyntz did you plan to maintain this lib/repository?
same problem
+1
@Fomin2402 @Nasun4o @wisdomrider
Although disabling aot
generates build successfully.
CC: @AndrewPoyntz
+1
Setting Pipe.pure to "true" and I was confirm it works as expected roughly.
Setting Pipe.pure to "true" and I was confirm it works as expected roughly.
How would you do that?
Does not work with Angular 9. Do you have any suggestions?
Does not work with Angular 9. Do you have any suggestions? Hello, ilkeryanizca you must do what Fomin2402 did in his post.
Setting Pipe.pure to "true" and I was confirm it works as expected roughly.
How would you do that?
Follow the method provided by @Fomin2402 .
Steps
Hello, I have the same issue but using @Fomin2402 code raise an error:
Classes decorated with @Pipe decorator should implement PipeTransform interface.
Hello everyone and thanks for your answers. I use 'time-ago-pipe', and it works pretty well. I would recommend. Have a nice day.
Seems to be the same issue with JsonPipe.
It does work in Angular 9 with one little modification:
import {Pipe, PipeTransform} from '@angular/core';
import {TimeAgoPipe} from 'time-ago-pipe';
@Pipe({
name: 'timeAgo',
pure: false
})
export class TimeAgoExtendsPipePipe extends TimeAgoPipe implements PipeTransform {
transform(value: string): string {
return super.transform(value);
}
}
Note that you have to implement PipeTransform in order to not get compilation error on @Pipe
.
Not sure why I both have to extend a class which implements an interface AND implement the interface. But this TimeAgo has caused me enough troubles now, so I'm happy enough as long as it is working.
It does work in Angular 9 with one little modification:
import {Pipe, PipeTransform} from '@angular/core'; import {TimeAgoPipe} from 'time-ago-pipe'; @Pipe({ name: 'timeAgo', pure: false }) export class TimeAgoExtendsPipePipe extends TimeAgoPipe implements PipeTransform { transform(value: string): string { return super.transform(value); } }
Note that you have to implement PipeTransform in order to not get compilation error on
@Pipe
. Not sure why I both have to extend a class which implements an interface AND implement the interface. But this TimeAgo has caused me enough troubles now, so I'm happy enough as long as it is working.
Hi! the code looks fine, but I still got errors upon compilation :(
EDIT: I got it just by converting my date to string :/
It does work in Angular 9 with one little modification:
import {Pipe, PipeTransform} from '@angular/core'; import {TimeAgoPipe} from 'time-ago-pipe'; @Pipe({ name: 'timeAgo', pure: false }) export class TimeAgoExtendsPipePipe extends TimeAgoPipe implements PipeTransform { transform(value: string): string { return super.transform(value); } }
Note that you have to implement PipeTransform in order to not get compilation error on
@Pipe
. Not sure why I both have to extend a class which implements an interface AND implement the interface. But this TimeAgo has caused me enough troubles now, so I'm happy enough as long as it is working.Hi! the code looks fine, but I still got errors upon compilation :(
EDIT: I got it just by converting my date to string :/
please tell me how to convert date to string
I'm getting this with Angular 10 (in Ionic). The fixes above (including @larsnedb's one ) don't help me.
Fine until I run a prod build. If I run ionic build --prod I get the error:
ERROR in node_modules/time-ago-pipe/time-ago.pipe.d.ts:3:22 - error NG6002: Appears in the NgModule.imports of PipesModule, but could not be resolved to an NgModule class.
This likely means that the library (time-ago-pipe) which declares TimeAgoPipe has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.
EDIT: I ended up switching to ngx-pipes as it has a timeAgo
@Fomin2402 Hello, can you please share with us which is the error you got ? to know if this issue concerns my problem too or not .
thank you in advance
Slight modification to allow dates:
import { Pipe, PipeTransform } from '@angular/core';
import { TimeAgoPipe } from 'time-ago-pipe';
@Pipe({
name: 'timeAgo'
})
export class TimeagoFixPipe extends TimeAgoPipe implements PipeTransform {
transform(value: Date | string): string {
return super.transform(value.toString());
}
}
I have an error in console, when try to import TimeAgoPipe and add to module declarations.
So, little "crutch" like that solved my problem