Angular2 If ngModel is used within a form tag, either the name attribute must be set or the form

前端 未结 14 2304
借酒劲吻你
借酒劲吻你 2020-12-04 07:33

I am getting this error from Angular 2

core.umd.js:5995 EXCEPTION: Uncaught (in promise): Error: Error in app/model_exposure_currencies/model_exposure_cu

14条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 07:49

    It's quite easy for a fix.

    For me, we had more than one inputs in the form. We need to isolate the input / line causing error and simply add the name attribute. That fixed the issue for me:

    Before:


           
    

              {{option}
          
        
    
        
          Enter number
    

            
    

        
    

        Check! 
    

      
    

    After: i just added the name attribute for select and checkbox and that fixed the issue. As follows:

     
    
      
    
    Check! 
    

    As you see added the name attribute. It is not necessary to be given same as your ngModel name. Just providing the name attribute will fix the issue.

提交回复
热议问题