I have an Angular 2 application, where I have implemented a pipe to basically check some null values. Problem is when I use map() I get the below error:
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
Below you can take a look my code:
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;
}
}
I think the code is ok, you can take a look an example I have write here: link
any idea what its going on with my code? thanks!
import 'rxjs/add/operator/map'or import all operators withimport 'rxjs/Rx';