Skip to content

Commit c0a81fe

Browse files
authored
[Angular] Migrate to signals (translate.directive.ts) (#28196)
1 parent d729991 commit c0a81fe

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

generators/angular/templates/src/main/webapp/app/shared/language/translate.directive.ts.ejs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
See the License for the specific language governing permissions and
1717
limitations under the License.
1818
-%>
19-
import { inject, Input, Directive, ElementRef, OnChanges, OnInit, OnDestroy } from '@angular/core';
19+
import { inject, input, Directive, ElementRef, OnChanges, OnInit, OnDestroy } from '@angular/core';
2020
import { TranslateService } from '@ngx-translate/core';
2121
import { Subject } from 'rxjs';
2222
import { takeUntil } from 'rxjs/operators';
@@ -30,8 +30,8 @@ import { translationNotFoundMessage } from 'app/config/translation.config';
3030
selector: '[<%= jhiPrefix %>Translate]',
3131
})
3232
export default class TranslateDirective implements OnChanges, OnInit, OnDestroy {
33-
@Input() <%= jhiPrefix %>Translate!: string;
34-
@Input() translateValues?: Record<string, unknown>;
33+
readonly <%= jhiPrefix %>Translate = input.required<string>();
34+
readonly translateValues = input<Record<string, unknown>>();
3535

3636
private readonly directiveDestroyed = new Subject();
3737

@@ -58,13 +58,13 @@ export default class TranslateDirective implements OnChanges, OnInit, OnDestroy
5858

5959
private getTranslation(): void {
6060
this.translateService
61-
.get(this.<%= jhiPrefix %>Translate, this.translateValues)
61+
.get(this.<%= jhiPrefix %>Translate(), this.translateValues())
6262
.pipe(takeUntil(this.directiveDestroyed))
6363
.subscribe({
6464
next: value => {
6565
this.el.nativeElement.innerHTML = value;
6666
},
67-
error: () => `${translationNotFoundMessage}[${this.<%= jhiPrefix %>Translate}]`
67+
error: () => `${translationNotFoundMessage}[${this.<%= jhiPrefix %>Translate()}]`
6868
});
6969
}
7070
}

0 commit comments

Comments
 (0)