ws-form-builder
Version:
Ionic 2 Form Builder
86 lines (62 loc) • 2.07 kB
text/typescript
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { FormBuilderProvider } from '../../providers/form-builder/form-builder';
import { ModalController } from 'ionic-angular';
export class WsDatePickerComponent {
question;
answerGiven = new EventEmitter();
fieldValue:string = '';
isFieldValid:boolean = false;
showError:boolean = false;
dateFormat:string = 'DD/MM/YYYY';
fieldClass:string = '';
constructor(
public formBuilder: FormBuilderProvider,
public modalCtrl: ModalController
//private datePickerProvider: DatePickerProvider
){
this.fieldValue = '';
}
ngOnInit() {
if(typeof this.question.value !== 'undefined'){
this.fieldValue = this.question.value;
}
if(typeof this.question.dateFormat !== 'undefined'){
this.dateFormat = this.question.dateFormat;
}
if(typeof this.question.inputClass !== 'undefined'){
this.fieldClass = this.question.inputClass;
}
}
setAnswer(event,question){
//let data = moment(date).format('DD/MM/YYYY');
question.date = this.fieldValue;
question.value = this.fieldValue;
question.valid = true;
//this.fieldValue = data;
this.answerGiven.emit(question);
//let isStringValid = this.validateAnswer(date);
/*if(!isStringValid){
this.isFieldValid = false;
this.showError = true;
}else{
this.isFieldValid = true;
this.showError = false;
}
if(this.isFieldValid){*/
//}
}
validateAnswer(question,string){
return this.formBuilder.validateAnswer(question,string);
}
}