Project

General

Profile

1
/**
2
 * Created by stefanos on 28/4/2017.
3
 */
4

    
5
import {Component, OnInit, Input} from '@angular/core';
6
import {FormGroup, FormBuilder, Validators} from "@angular/forms";
7

    
8

    
9
@Component({
10
    selector: 'topics-form',
11
    templateUrl: './topics-form.component.html',
12
})
13

    
14
export class TopicsFormComponent implements OnInit{
15

    
16
    @Input('group')
17
    myForm: FormGroup;
18

    
19
    constructor(private _fb: FormBuilder){}
20

    
21
    ngOnInit(): void {
22
    }
23

    
24
    public get form() {
25
        return this._fb.group({
26
            name : ['', Validators.required],
27
            description : '',
28
            weight : ['0.0', Validators.required],
29
            questionOrder : 'hits',
30
            _id : ''
31
            // date : '',
32
        });
33
    }
34

    
35
    public reset() {
36
        this.myForm.patchValue({
37
            name : '',
38
            description : '',
39
            weight : '0.0',
40
            questionOrder : 'hits',
41
            _id : ''
42
        });
43
        this.myForm.markAsPristine();
44
    }
45

    
46
}
(6-6/8)