I am using a few pretty standard custom pipes in my Angular 2.0-rc1 app. All was well until I moved the pipes to a new folder. Now I am getting:
zone.js:461 Unhandled Promise rejection: No Pipe decorator found on RoomDetailWidgetComponent ; Zone: angular ; Task: Promise.then ; Value: BaseException {message: "No Pipe decorator found on RoomDetailWidgetComponent", stack: "Error: No Pipe decorator found on RoomDetailWidget…/@angular/compiler/src/runtime_compiler.js:66:49)"}message: "No Pipe decorator found on RoomDetailWidgetComponent"stack: "Error: No Pipe decorator found on RoomDetailWidgetComponent↵ at new BaseException (http://localhost:5000/lib/@angular/compiler/src/facade/exceptions.js:17:23)↵ at PipeResolver.resolve (http://localhost:5000/lib/@angular/compiler/src/pipe_resolver.js:29:15)↵ at CompileMetadataResolver.getPipeMetadata (http://localhost:5000/lib/@angular/compiler/src/metadata_resolver.js:142:47)↵ at eval (http://localhost:5000/lib/@angular/compiler/src/metadata_resolver.js:173:57)↵ at Array.map (native)↵ at CompileMetadataResolver.getViewPipesMetadata (http://localhost:5000/lib/@angular/compiler/src/metadata_resolver.js:173:22)↵ at eval (http://localhost:5000/lib/@angular/compiler/src/runtime_compiler.js:80:58)↵ at Array.forEach (native)↵ at RuntimeCompiler._compileComponent (http://localhost:5000/lib/@angular/compiler/src/runtime_compiler.js:76:36)↵ at eval (http://localhost:5000/lib/@angular/compiler/src/runtime_compiler.js:66:49)"proto: ErrorconsoleError @ zone.js:461_loop_1 @ zone.js:490drainMicroTaskQueue @ zone.js:494ZoneTask.invoke @ zone.js:426 zone.js:463 Error: Uncaught (in promise): No Pipe decorator found on RoomDetailWidgetComponent(…)consoleError @ zone.js:463_loop_1 @ zone.js:490drainMicroTaskQueue @ zone.js:494ZoneTask.invoke @ zone.js:426
import { Component, AfterViewInit, Input, SimpleChange, Output, EventEmitter } from "@angular/core";
import { IPropertyRoom } from "./../../shared/propertyData";
import { FirstHalfPipe } from "./../../shared/pipes/first-half.pipe";
import { SecondHalfPipe } from "./../../shared/pipes/second-half.pipe";
export interface IRoomData {
roomId: number;
isFeatured: boolean;
roomName: string;
featurePicSrc: string;
description: string;
amenities: string[];
}
@Component({
selector: "room-detail-widget",
templateUrl: "app/mobile/roomDetailWidget/room-detail-widget.html",
directives: [],
pipes: [FirstHalfPipe,SecondHalfPipe]
})
export class RoomDetailWidgetComponent {
@Input() roomDetail: IRoomData;
@Output() onRoomTabClick = new EventEmitter();
constructor() {
}
ngOnChanges(changes: { [propName: string]: SimpleChange }) {
this.roomDetail = changes["roomDetail"].currentValue;
}
roomClick() {
this.onRoomTabClick.emit(this.roomDetail.roomId);
}
}
As you can see, I am declaring the pipes in my component. The paths are all ok. Can't figure out how to fix this.
As it turned out it was a "dumb" error.
I accidentally referenced the offending component as a pipe, rather than a directive, in the parent component as follows:
import { RoomDetailWidgetComponent, IRoomData } from "./../roomDetailWidget/room-detail-widget.component"
@Component({
directives: [],
selector: "parent",
templateUrl: "path/parent.html",
pipes: [RoomDetailWidgetComponent] //Duh, big FAIL
})
export class ParentComponent {
constructor() {
}
}
Hopefully this will help avert headache for somebody else. Easy mistake to make...