convert exiting to use deprecated name converted to new api text warnings fix plunker text test weak text space text lint order tweak
		
			
				
	
	
		
			21 lines
		
	
	
		
			604 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			604 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| // #docregion
 | |
| import { Injectable }   from '@angular/core';
 | |
| import { FormControl, FormGroup, Validators } from '@angular/forms';
 | |
| 
 | |
| import { QuestionBase } from './question-base';
 | |
| 
 | |
| @Injectable()
 | |
| export class QuestionControlService {
 | |
|   constructor() { }
 | |
| 
 | |
|   toFormGroup(questions: QuestionBase<any>[] ) {
 | |
|     let group: any = {};
 | |
| 
 | |
|     questions.forEach(question => {
 | |
|       group[question.key] = question.required ? new FormControl(question.value || '', Validators.required)
 | |
|                                               : new FormControl(question.value || '');
 | |
|     });
 | |
|     return new FormGroup(group);
 | |
|   }
 | |
| }
 |