I'm quite new in Angular. I looked for answers in doc and stackoverflow but I haven't found it. So, sorry if my question is obvius.
I created a component to hold my modal content in a separated file. I open this modal using open.dialog like this from parent component:
openMyModalDialog() {
const dialogRef = this.dialog.open(MyModalComponent, {
panelClass: 'own-modal',
width: '300px'
});
dialogRef.afterClosed().subscribe(result => {
alert('closed');
});
}
Well, MyModalComponent:
<h1 mat-dialog-title>{{ 'myTargetTranslateKey' | translate }}</h1>
<div mat-dialog-content>
<p>What's your favorite animal?</p>
<mat-form-field>
<mat-label>Favorite Animal</mat-label>
</mat-form-field>
</div>
<div mat-dialog-actions>
<button mat-button (click)="onNoClick()">No Thanks</button>
</div>
I don't import TranslateModule in the modal component, because I think that's imported in the module.
...
@NgModule({
imports: [
CommonModule,
TranslateModule,
MomentModule,
IMaskModule,
It's also imported in app.module.ts. using TranslateModule.forRoot().
It's important to say that | translate pipe works in any other components / code, also in the parent which opens the dialog.
Thanks in advance!
UPDATE: I've imported TranslateService from ngx-translate/core in the modal component. I put a console.log on close event, and I can see that this.translateSevice.instant('key') works!... So the problem is the pipe doesn't work.
UPDATE 2: It also works with <h1 mat-dialog-title [translate]="'key'"></h1> but it doesn't with the pipe! :'(
UPDATE 3: Pipe doesn't work means that the result is empty, nothing is displayed but there aren't errors in the console neither.
the pipe 'translate' could not be found? - Anton Temchenko'translate' could not be foundfrom which I've been reading. Maybe, another clue, I'm having also problems (I work with Material Angular) injecting data to a dialog. I can't see in the template, but I see the data injected if I console.log. - dmanso