Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component, OnInit } from '@angular/core';
- import { FormBuilder, FormGroup, Validators, FormArray, FormControl } from '@angular/forms';
- import { ActivatedRoute, Router } from '@angular/router';
- import { QuestionService } from '../shared/question.service';
- @Component({
- selector: 'app-update-que',
- templateUrl: './update-que.component.html',
- styleUrls: ['./update-que.component.scss']
- })
- export class UpdateQueComponent implements OnInit {
- questionsTypes = ['Text Type', 'Multiple choice', 'Single Select'];
- selectedQuestionType: string = "";
- question: any = {};
- constructor(private route: ActivatedRoute, private router: Router,
- private qService: QuestionService, private fb: FormBuilder) {
- }
- ngOnInit() {
- this.getQuebyid();
- }
- getQuebyid(){
- this.route.params.subscribe(params => {
- this.qService.editQue([params['id']]).subscribe(res =>{
- this.question = res;
- });
- });
- }
- editqueForm = this.fb.group({
- user: [''],
- questioning: ['', Validators.required],
- questionType: ['', Validators.required],
- options: new FormArray([])
- })
- setValue(){
- this.editqueForm.setValue({user: this.question.user, questioning: this.question.questioning})
- }
- }
- <textarea formControlName="questioning" [(ngModule)]="question.questioning" cols="70" rows="4"></textarea>
- setValue(){
- this.editqueForm.setValue({user: this.question.user, questioning: this.question.questioning})
- }
- setValue(){
- this.editqueForm.patchValue({user: this.question.user, questioning: this.question.questioning})
- }
- this.editqueForm.patchValue({
- user: this.question.user,
- questioning: this.question.questioning
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement