I am currently working on project, I created a new pipe but it is showing an error. I don't know what this error means and how solve it.
(method) SumPipe.transform(value: any, currancy: string): any
This member must have an 'override' modifier because it overrides a member in the base class 'CurrencyPipe'.
import { CurrencyPipe } from '@angular/common';
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'sumPipe',
})
export class SumPipe extends CurrencyPipe implements PipeTransform {
transform(value: any, currancy: string): any {
if (value == '-') return '-';
let symbol;
switch (currancy) {
case 'MYR':
symbol = 'RM';
break;
case 'GBP':
symbol = '£';
break;
case 'SGD':
symbol = 'SGD';
break;
case 'CAD':
symbol = 'CAD';
break;
case 'IDR':
symbol = 'Rp';
break;
case 'EUR':
symbol = '€';
break;
default:
symbol = currancy;
break;
}
if (value) {
value = super.transform(value);
value = value.replace('$', '');
if (value < 0) {
value = '-' symbol value * -1;
} else {
value = symbol value;
}
return value;
} else {
return symbol ' 0';
}
}
}
```
I searched for the solution but cant find
CodePudding user response:
You are extending the CurrencyPipe, which also has a transform method. Thats why typescript wants to to add the override keyword. (read further)
export class SumPipe extends CurrencyPipe implements PipeTransform {
override transform(value: any, currancy: string): any {