angular-jsf-components
Version:
JSF Compliant Angular Components
67 lines (58 loc) • 2.09 kB
text/typescript
import {AfterContentInit, AfterViewInit, Component, ElementRef, forwardRef, Input,} from '@angular/core';
import {NG_VALUE_ACCESSOR, NgModel} from '@angular/forms';
import {HFormService} from '../../services/h-form.service';
import {MessageService} from '../../services/message.service';
import {JsfElement} from '../../superclass/jsf-element';
import {JsfInput} from '../../superclass/jsf-input';
import {JsfSelectOne} from '../../superclass/jsf-select-one';
export class HSelectOneRadioComponent extends JsfSelectOne implements AfterContentInit, AfterViewInit {
layout: string;
model: NgModel;
constructor(messageService: MessageService, formService: HFormService,
elementRef: ElementRef) {
super(formService, messageService, elementRef);
this.radioCallback = this.radioCallback.bind(this);
this.getCurrentValue = this.getCurrentValue.bind(this);
}
getCurrentValue() {
return this.innerValue;
}
radioCallback(event: any) {
this.value = event.target.value;
}
ngAfterContentInit() {
super.ngAfterContentInit();
for (const item of this.items) {
item.currentValue = this.getCurrentValue;
item.radioCallback = this.radioCallback;
}
}
ngAfterViewInit() {
super.ngAfterViewInit();
for (const item of this.items) {
item.currentValue = this.getCurrentValue;
item.radioCallback = this.radioCallback;
}
}
}