2016-04-27 35 views
0

TSクラスをインポートするために1つのファイルを使用しようとすると、私の角度2アプリケーションをロードするときに、私は次のエラーを取得しています:角度2エラー

EXCEPTION: Error: Uncaught (in promise): Unexpected piped value 'undefined' on the View of component 'DashboardComponent' 

奇数部分は、私は、この行のコメントを解除し、削除した場合ということです「CustomPipe」「appCore」からの参照は、それが再び動作します:

//import {CustomPipe} from "../shared/customPipe" 

をこれは何とか私は私の「親」エクスポートファイル「appCore.ts」を使用している場合、正しくクラスをエクスポート/インポートするわけではないなら、私は思ってしまいますかおそらく角度2で何らかの問題があります。

何か間違っていますか?

Example Project on Github

CustomPipe.ts

import {Pipe, PipeTransform} from "angular2/core" 

@Pipe({ name: "CustomPipe" }) 
export class CustomPipe implements PipeTransform 
{ 
    constructor() 
    { 
     console.log("created"); 
    } 
    public transform(value: string, args: any[]): string 
    { 
     return "this value has been transformed into me via a custom pipe"; 
    } 
} 

appCore.ts

export * from "./dashboard/dashboardComponent" 
export * from "./vehicles/VehicleListComponent" 
export * from "./vehicles/VehicleComponent" 
export * from "./shared/nestedComponent" 
export * from "./interfaces/IVehicleService" 
export * from "./shared/staticVehicleService" 
export * from "./shared/VehicleService" 
export * from "./shared/customPipe" 

dashboardComponent.ts

import {Component, Output, EventEmitter, OnInit, Inject, Injectable, provide, OpaqueToken} from "angular2/core" 
import {CustomPipe, IVehicleService, StaticVehicleService} from "../appCore" 
//import {CustomPipe} from "../shared/customPipe" 
import {NestedComponent} from "../shared/nestedComponent" 
import {Observable} from "rxjs/Rx" 
import {IVehicleServiceToken} from "../interfaces/IVehicleService" 

@Component({ 
    selector: "my-app", 
    templateUrl: "./app/dashboard/dashboardComponent.html", 
    styleUrls: ["./app/dashboard/dashboardComponent.css"], 
    directives: [NestedComponent], 
    pipes: [CustomPipe] 
}) 
export class DashboardComponent implements OnInit 
{ 
} 

E dit: Here is a Plunker of the issue: app/characters/character-list.component.ts行を見てください。5 & 6. plunkは機能しませんが、6行目のコメントを外して5行目の "CharacterService"を削除すると動作します。

+0

どの角度バージョンをお使いですか?すでにベータ16? –

+0

私はbeta15を使用していましたが、@ tibbusのアドバイスに従って、package.json内の他のものと一緒にベータ版に更新しましたが、問題は引き続き発生します。 – Sharpiro

答えて

0

コードは大丈夫です。私は自分のアプリで複製しようとしたが、私はあなたのエラーを得ることはできません。
Angular2の古い依存関係があるかもしれないと思うので、すべてのパッケージを最新のものに更新することをお勧めします。

間違ったnpm依存バージョンを使用すると、同様のエラーがhereに発生することがあります。 Unexpected piped value 'undefined' on the View of component

+0

GitHubソリューションをすべての最新パッケージにアップデートしても問題は解決しません。私も最新のタイスクリプト版を自分のPCにインストールしています。 – Sharpiro

0

私は同じ奇妙なエラー(angular-2-0.0.rc4)に遭遇しました。 私の最後のインポートは私のパイプであり、インポート行を上に移動することによって、エラーはなくなりました。なぜ私は考えていない。パイプの輸入ラインを上げようとしましたか?

わかりませんが、私の問題は解決しました。