0
Hello, I have a Pipe that turns a number into a string saying the referring month.
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'nomeMesPipe',
})
export class NomeMesPipe implements PipeTransform {
transform(value: any): any {
if (value) {
switch (
value // Converte o numero em nome do mês
) {
case 0:
value = 'Janeiro';
break;
case 1:
value = 'Fevereiro';
break;
case 2:
value = 'Março';
break;
case 3:
value = 'Abril';
break;
case 4:
value = 'Maio';
break;
case 5:
value = 'Junho';
break;
case 6:
value = 'Julho';
break;
case 7:
value = 'Agosto';
break;
case 8:
value = 'Setembro';
break;
case 9:
value = 'Outubro';
break;
case 10:
value = 'Novembro';
break;
case 11:
value = 'Dezembro';
break;
}
}
return '';
}
}
This pipe is exported and declared in a module called Shared module. .
declarations: [
...
NomeMesPipe,
...
],
exports: [
...
NomeMesPipe,
...
],
which in turn is exported and importing into my app.modulets.
exports: [SharedModule],
imports: [
...
SharedModule
...
],
and used in my component as {{ data.mes |nameMesPipe }}. This component has a module but I don’t mind the pipe here because it’s already in the app..
However it presents error.
Error: Uncaught (in Promise): Error: Template parse errors: The pipe 'nameMesPipe' could not be found
I have tried to leave only in the module Shared, I have tried to leave in the module of the component, and also I have tried to put in the two modules, but I was not successful.
theoretically have to be in the export of your Shared module
– Eduardo Vargas
i fixed the question text, actually, it is already in Shared module export and not import.
– paulotarcio
tries to import Sharedmodule in the module that you let this component
– Eduardo Vargas