closes #1095 control value now will be initialized with 'question.value', regardless if the control has validation of 'required' or not.
		
			
				
	
	
		
			19 lines
		
	
	
		
			549 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			19 lines
		
	
	
		
			549 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
// #docregion
 | 
						|
import { Injectable }   from '@angular/core';
 | 
						|
import { ControlGroup, FormBuilder, Validators } from '@angular/common';
 | 
						|
import { QuestionBase } from './question-base';
 | 
						|
 | 
						|
@Injectable()
 | 
						|
export class QuestionControlService {
 | 
						|
  constructor(private fb:FormBuilder){ }
 | 
						|
 | 
						|
  toControlGroup(questions:QuestionBase<any>[] ) {
 | 
						|
    let group = {};
 | 
						|
 | 
						|
    questions.forEach(question => {
 | 
						|
      group[question.key] = question.required ? [question.value || '', Validators.required] : [question.value || ''];
 | 
						|
    });
 | 
						|
    return this.fb.group(group);
 | 
						|
  }
 | 
						|
}
 |