Angular 2: 'ngFormModel' since it isn't a known native property

前端 未结 3 1483
故里飘歌
故里飘歌 2020-12-20 11:48

My error is

 EXCEPTION: Error: Uncaught (in promise): Template parse errors:
Can\'t bind to \'ngFormModel\' since it isn\'t a kn         


        
3条回答
  •  失恋的感觉
    2020-12-20 12:13

    Just import the following statement in ts,

    import {FORM_DIRECTIVES, FormBuilder, Validators, REACTIVE_FORM_DIRECTIVES} from '@angular/forms';
    directives: [CORE_DIRECTIVES, ROUTER_DIRECTIVES, FORM_DIRECTIVES, REACTIVE_FORM_DIRECTIVES],
    

    Make the following changes in templates,

    MY PROFILE

    First name is required
    Last name is required
    Phone number is required

    Finally do this in your bootstrapping,

    import {provideForms, disableDeprecatedForms} from '@angular/forms';
    bootstrap(MyDemoApp, [
    provideForms(),
    disableDeprecatedForms()]);
    

提交回复
热议问题