Analogue of Angular 2 Provider

2019-02-27 19:58发布

I have a custom component for checkbox.

const CheckboxValue = new Provider(
        NG_VALUE_ACCESSOR, {
        useExisting: forwardRef(() => CheckboxComponent),
        multi: true
    });

@Component({
               ...
               providers: [CheckboxValue]
           })
export class CheckboxComponent implements ControlValueAccessor {
    ...
}

As I understood in RC3 Provider was marked as deprecated. How I must rewrite my Component so that he working after next update?

1条回答
狗以群分
2楼-- · 2019-02-27 20:35

It now takes an object like:

const CheckboxValue = {
    provide: NG_VALUE_ACCESSOR, 
    useExisting: forwardRef(() => CheckboxComponent),
    multi      : true
}

Update

If you get "No value accessor for ''" in RC.3 new forms see Custom component binding: No value accessor for ''

查看更多
登录 后发表回答