I use the bootstrap tooltip like this :
<em class="fas fa-hand-paper cursor-pointer" data-toggle="tooltip" data-placement="top" title="{{displayMessage(statut)}}" [attr.aria-label]="displayMessage(statut)"></em>
For the title of the tooltip I use a function which returns me a different value according to the parameters :
title="{{displayMessage(statut)}}"
and :
public tooltipMessage: string;
public displayMessage(value) {
if (value != null) {
this.translate
.get(`TOOLTIP.ICON.${value}`)
.subscribe((res: string) => {
this.tooltipMessage = res
return this.tooltipMessage;
})
}
console.log(this.tooltipMessage);
}
For the translation I use ngx-translate for two languages.
The problem:
When I switch to the tooltip the title is displayed according to the language but when I change the translation the title of the tooltip does not reset, I have to reload the page to display the title translated in the correct language.
I tried using the "onLangChange" function of ngx-translate.
public ngOnInit() {
this.subscriptions.add(
this.translate.onLangChange.subscribe((event: LangChangeEvent) => {
this.displayMessage(this.statut);
})
);
}
But unfortunately without success
The most astonishing if I control the console.log(this.tooltipMessage); this last returns the translation well but does not update the html.
Do you have a solution for this problem?