Angular 2 Form “Cannot find control with path”

前端 未结 5 1499
无人共我
无人共我 2020-11-30 03:36

I try to make a dynamic form (so you can limitless add items to a list), but somehow the content of my list is not getting send because it can\'t find the control with path:

5条回答
  •  醉梦人生
    2020-11-30 04:29

    I also encountered this error, and I solved this problem by initiating the variables of class(elements in this.fb.array([])).

    Code Snippet

        mobileNumbers: this.fb.array([this.fb.group(new MobileNumber('IN'))]),
    

    Where class MobileNumber is used.

    export class MobileNumber{
        public country_code: string;
        public mobile_number: string;
        constructor($cc){
            this.country_code = COUNTRY_CODES[$cc];
        }
    }
    

    To

    export class MobileNumber{
        public country_code = '';
        public mobile_number = '';
        constructor($cc){
            this.country_code = COUNTRY_CODES[$cc];
        }
    }
    

提交回复
热议问题