简体   繁体   中英

Custom component binding: No value accessor for ''

I updated my form with a custom element to @angular/forms as of RC2. When I perform an input binding on it using [(ngModel)]="myModel" , I get No value accessor for '' from angular and the form fails to load. The error only occurs with input binding.

Here's a plunker illustrating the issue: https://plnkr.co/edit/wxMsGuxr3GHMwNNoczT7?p=preview

The value accessor is generally working (and the model did with the old forms stuff in RC1) because the FormBuilder has an initial value which is correctly set through the accessor interface.

The issue seems similar to https://github.com/angular/angular/issues/7518 but the form directives are provided in the bootstrap code:

provideForms(),
{
    provide: PLATFORM_DIRECTIVES,
    useValue: [REACTIVE_FORM_DIRECTIVES],
    multi: true
}

You are missing disableDeprecatedForms() in the call to bootstrap. See here: https://plnkr.co/edit/tk1rWdmXB7umkGPYK4Ho?p=preview

I got the same problem yesterday and this solution didn't solved it at first. To make it work, I had to clear my browser cache.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM