Angular2无提供商渲染! (NgModel - >令牌NgValueAccessor ​​ - > DefaultValueAccessor ​​ - >渲染器) [英] Angular2 No provider for Renderer! (NgModel -> Token NgValueAccessor -> DefaultValueAccessor -> Renderer)

查看:797
本文介绍了Angular2无提供商渲染! (NgModel - >令牌NgValueAccessor ​​ - > DefaultValueAccessor ​​ - >渲染器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

shlomiassaf / angular2模态定制模式customModal.ts的。
具体的,我添加了一个输入含有ngModel,它进口FORM_DIRECTIVES和指令。

I custom modal of customModal.ts in shlomiassaf/angular2-modal. Specific, i add a input contain ngModel, it imported FORM_DIRECTIVES and directives.

问题时运行不供应商渲染! (NgModel - >令牌NgValueAccessor ​​ - > DefaultValueAccessor ​​ - >渲染器)

The issue when run 'No provider for Renderer! (NgModel -> Token NgValueAccessor -> DefaultValueAccessor -> Renderer)'

请帮我resovle这个问题。
谢谢你。

Please help me resovle this issue. Thanks.

推荐答案

我看到两种可能性:


  • 而不是在组件或应用程序级别指定相应的提供者。我不认为这个问题,因为我已经注入渲染,而不在其提供商属性或内有指定,在引导函数的第二个参数。

  • The corresponding provider isn't specified at the component or application level. I don't think that the problem because I already inject a Renderer without having specified it in its providers attribute or within the second parameter of the bootstrap function.

类似的东西:

    import {Component,Renderer,ElementRef} from 'angular2/core';

    @Component({
      selector: 'child',
      template: '<div></div>',
    })
    export class ChildComponent {
      constructor(private _renderer: Renderer,
               private el: ElementRef) {
        (...)
      }
    }


  • 我认为这将是而是因为那里的渲染注入不装饰类,所以依赖注入不能适用。正如本评论强调,需要有这样的才能注入。 注射未对注入的东西,但对于注入本身。

    • I think it would be rather because the class where the renderer is injected isn't decorated so dependency injection can't apply. As emphasized in this comment, you need to have this to be able to inject. Injectable isn't for be injected into something but for injecting into itself.
    • 修改

      在看看你的code后,看来你需要渲染器添加到您提供给 loadNextToLocation 方法提供者列表。你可以更新这样的 DialogService#打开方法code:

      After having a look at your code, it seems that you need to add the renderer to the list of providers you provide to the loadNextToLocation method. You could update the code of the DialogService#open method like this:

      var otherResolved = Injector.resolve([
        provide(DialogRef, { useValue: dialogRef})
        provide(Renderer, { useValue: this.renderer})
      ]);
      

      希望它可以帮助你,
      蒂埃里

      Hope it helps you, Thierry

      这篇关于Angular2无提供商渲染! (NgModel - &GT;令牌NgValueAccessor ​​ - &GT; DefaultValueAccessor ​​ - &GT;渲染器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆