import {AfterViewInit, Component, OnInit} from '@angular/core'; import {FieldType} from '@ngx-formly/material'; @Component({ selector: 'jhi-radio-custom', templateUrl: './radio-custom.component.html', styleUrls: ['./radio-custom.component.scss'] }) export class RadioCustomComponent extends FieldType implements OnInit, AfterViewInit { radioOptions: any[] = []; constructor() { super(); } ngOnInit(): void { this.replaceByModelValue(); } ngAfterViewInit() { this.setOptions(); } setOptions(): void { if (this.field && this.field.templateOptions && this.field.templateOptions.options) { this.field.templateOptions.options.forEach((option: any) => { this.radioOptions.push(option); }); } } replaceByModelValue(): void { const label = this.field.templateOptions.label; const reg = /\$_\[(.*?)\]/g; let m; do { m = reg.exec(label); if (m) { this.field.templateOptions.label = this.field.templateOptions.label.replace('$_[' + m[1] + ']', this.model[m[1]]); } } while (m); } }