Error:
Issue: Template parse errors: The 'datefromiso' pipe is not recognized
Custom Pipe:
import {Pipe, PipeTransform} from "@angular/core";
@Pipe({
name: 'datefromiso'
})
export class DateFromISO implements PipeTransform {
transform(value: any, args: string[]): string {
if (value) {
var date = value instanceof Date ? value : new Date(value);
return date.getDate() + '/' + (date.getMonth()+1) + '/' + (date.getYear()+1900);
}
}
}
App module:
import { DateFromISO } from './pipes/date-from-iso';
...
@NgModule({
bootstrap: [ App ],
declarations: [
App,
ErrorComponent,
DateFromISO
]
HTML:
<div class="pull-right">{{entity.ts | datefromiso}}</div>
The value of entity.ts
is in ISO format. What might be causing the problem?
And a question: Is there a more efficient way to convert an ISO string to a local date using Angular 2 in HTML?
Thank you in advance.