Analogue of Angular 2 Provider

我怕爱的太早我们不能终老 提交于 2019-12-02 10:51:35

问题


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:


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 ''



来源:https://stackoverflow.com/questions/38138584/analogue-of-angular-2-provider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!