Cannot find control with name: formControlName in angular reactive form

前端 未结 6 1024
無奈伤痛
無奈伤痛 2020-12-25 11:47

I found this problem in many questions in stackoverflow but no luck. Please help me for figuring out what I am doing wrong.

In component :

6条回答
  •  -上瘾入骨i
    2020-12-25 12:24

    In your HTML code

    In your Typescript code

    export class UserprofileComponent implements OnInit {
        userForm: FormGroup;
        constructor(){ 
           this.userForm = new FormGroup({
              UserFirstName: new FormControl(),
              UserLastName: new FormControl()
           });
        }
    }
    

    This works perfectly, it does not give any error.

提交回复
热议问题