Reputation: 19
Onclick my request, the content Are you sure? is not changing to the required language.
list.component.html
<button type="button" (click)="myrequest(item.Id)">Request View</button>
list.component.ts
myrequest((Id: number));
{
this.notificationService.smartMessageBox(
{
title: "Warning",
content: "{{ 'Are you sure?' | translate }}",
buttons: "[No][Yes]"
},
ButtonPressed => {
if (ButtonPressed === "Yes") {
this.loading = true;
this.FurtherRequest(projectId).subscribe((data: any) => {
this.loading = false;
if (data.Success) {
this.notificationService.successMessage("request submitted");
} else {
this.notificationService.errorMessage(data.Message);
}
});
}
if (ButtonPressed === "No") {
}
}
);
}
list.module.ts
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
imports: [
TranslateModule],
exports: [
TranslateModule],
Unable to translate things inside js
Upvotes: 0
Views: 580
Reputation: 1627
Pipes do not work like this. You need to use translateService.get
or translateService.instant
to get a translation programatically.
Upvotes: 1
Reputation: 1526
You need to pass a parameter to translate pipe inside js file.
{{ 'Are you sure?' | translate :param }}
Upvotes: 1