angular2中standalone=“true”和Name attribute must be set if ngModel is used within a form的问题

时间:2022-03-01 15:59:41

使用[(ngModel)],说明是一个表单元素,如果简单的放在form中,可能会报错,必须要有name 属性,在表单中才有意义;或者使用 [ngModelOptions]="{standalone: true}属性,从form中独立出来,提交的时候不包含该标签。在form外使用无所谓有没有name属性。