Reputation: 47
When i use my service to print a message, the JhiAlertService tries to translate the message, how can i disable?
import { Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { JhiAlertService } from 'ng-jhipster';
@Injectable({
providedIn: 'root'
})
export class MessageServiceService {
constructor(public translate: TranslateService, public alertService: JhiAlertService) {
this.getTranslations();
}
getTranslations(){
this.clientError1 = this.translate.instant('global.error.clientError1');
this.clientError2 = this.translate.instant('global.error.clientError2');
}
printError(name, clientnumber) {
this.alertService.error(
this.clientError1 + name + this.clientError2 + clientnumber
);
}
}
Upvotes: 1
Views: 577
Reputation: 825
Unfortunately I have not found a way to not activate the translate;
however, to solve the problem it is sufficient to pass the variables between the parameters as follows:
String:
MSG_STR: "Hello {{user}}"
Alert command:
this.alertService.error(MSG_STR, {user: 'Max'}));
Result:
Hello Max
Upvotes: 2