在模型驱动表单中以编程方式设置formControl的值

时间:2016-11-11 21:12:16

标签: angular angular2-forms

如何获得以下函数的底线来设置类别表单字段的值?

ngOnInit() {
       this.findForm = this.formBuilder.group({
        categories: ['', [<any>Validators.required]],
        distanceNumber: ['', [<any>Validators.required]],
        distanceUnit: ['kilometers', [<any>Validators.required]],
        keywords: ['lemon', [<any>Validators.required]],
    });

    this.findForm.controls['categories'].updateValueAndValidity("shoe");
}

1 个答案:

答案 0 :(得分:8)

main