Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. import { Component, OnInit } from '@angular/core';
  2. import { FormBuilder, FormGroup, Validators, FormArray, FormControl } from '@angular/forms';
  3. import { ActivatedRoute, Router } from '@angular/router';
  4. import { QuestionService } from '../shared/question.service';
  5.  
  6. @Component({
  7. selector: 'app-update-que',
  8. templateUrl: './update-que.component.html',
  9. styleUrls: ['./update-que.component.scss']
  10. })
  11. export class UpdateQueComponent implements OnInit {
  12.  
  13. questionsTypes = ['Text Type', 'Multiple choice', 'Single Select'];
  14. selectedQuestionType: string = "";
  15. question: any = {};
  16. constructor(private route: ActivatedRoute, private router: Router,
  17. private qService: QuestionService, private fb: FormBuilder) {
  18.  
  19. }
  20.  
  21. ngOnInit() {
  22. this.getQuebyid();
  23. }
  24.  
  25. getQuebyid(){
  26. this.route.params.subscribe(params => {
  27. this.qService.editQue([params['id']]).subscribe(res =>{
  28. this.question = res;
  29. });
  30. });
  31. }
  32.  
  33. editqueForm = this.fb.group({
  34. user: [''],
  35. questioning: ['', Validators.required],
  36. questionType: ['', Validators.required],
  37. options: new FormArray([])
  38. })
  39.  
  40. setValue(){
  41. this.editqueForm.setValue({user: this.question.user, questioning: this.question.questioning})
  42. }
  43.  
  44. }
  45.  
  46. <textarea formControlName="questioning" [(ngModule)]="question.questioning" cols="70" rows="4"></textarea>
  47.  
  48. setValue(){
  49. this.editqueForm.setValue({user: this.question.user, questioning: this.question.questioning})
  50. }
  51.  
  52. setValue(){
  53. this.editqueForm.patchValue({user: this.question.user, questioning: this.question.questioning})
  54. }
  55.  
  56. this.editqueForm.patchValue({
  57. user: this.question.user,
  58. questioning: this.question.questioning
  59. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement