私は基本的にいくつかのnull値をチェックするパイプを実装している角度2のアプリケーションがあります。問題は、私はmap()
を使用するときに、私は以下のエラーを取得です:map()エラー2を使用して、角2&typescript
core.umd.js:2838 EXCEPTION: Uncaught (in promise): Error: Error in app/components/performances/performances.component.html:18:10 caused by: Cannot read property 'map' of undefined
TypeError: Cannot read property 'map' of undefined
をあなたは私のコードを見てとることができます以下:
import { Pipe, PipeTransform } from '@angular/core';
import {Performance} from '../common/performance';
@Pipe({
name: 'defaultPerformanceValueIfNull'
})
export class PerformanceCheckValuesPipe implements PipeTransform {
transform(values: Performance[]): any {
let performances = values.map(function(p) {
return Object.assign(p,
{
OneMonthBack: p.OneMonthBack || '-',
ThreeMonthsBack: p.ThreeMonthsBack || '-'
})
});
return performances;
}
}
私は、コードはOKだと思う、あなたは例を見てとることができますIここに書いてください: link
私のコードで何が起こっているのですか?感謝! ありがとう!
マップ演算子をインポートしてみましたか?つまり、 'import 'rxjs/add/operator/map''または' import'ですべての演算子をインポートするrxjs/Rx '; ' – Bean0341