Error:
Error: Template parsing errors: "datefromiso" in pipe cannot be found
Trumpet:
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); } } }
Application module:
import { DateFromISO } from './pipes/date-from-iso'; ... @NgModule({ bootstrap: [ App ], declarations: [ App, ErrorComponent, DateFromISO ]
HTML:
<div class="pull-right">{{entity.ts | datefromiso}}</div>
entity.ts is an ISO string. What's wrong? Also a question: if there is a better way to convert an ISO string to a localization date in html using angular2? Thanks in advance.
source share