-1
Error
ERROR Error: Staticinjectorerror(Appmodule)[Meucomponent -> Renderer]: Staticinjectorerror(Platform: core)[Meucomponent -> Renderer]:
Nullinjectorerror: No Provider for Renderer!
at _Nullinjector.get (core.js:1003)
resolveat Token (core.js:1301)
at tryResolveToken (core.js:1243)
At Staticinjector.get (core.js:1111)
resolveat Token (core.js:1301)
at tryResolveToken (core.js:1243)
At Staticinjector.get (core.js:1111)
resolveat NgModuleDep (core.js:10896)
at NgModuleRef_.get (core.js:12129)
resolveat NgModuleDep (core.js:10896)
Component
import { Component, OnInit, AfterViewInit, ViewChildren, ElementRef, Renderer, Renderer2, ViewChild } from '@angular/core';
constructor(private renderer: Renderer,private renderer2: Renderer2)
public showModal(modal: string): void {
if (modal == 'modalEditar') {
this.modalEditVisible = true;
this.modalAddVisible = false;
}
else if (modal == 'modalAdicionar') {
this.modalEditVisible = false;
this.modalAddVisible = true;
}
}
editar(obj) {
this.Component.Objeto= obj;
this.showModal('modalEditar');
}
HTML
<td>
<label (click)="editar(obj)" data-toggle="modal" data-target=".modal-obj-edit">
<i class="fa fa-pencil text-info"></i>
</label>
</td>
// Chamada do modal
<app-editar *ngIf="modalEditVisible != false" [(visible)]="modalEditVisible"></app-editar>
Modal
<div class="modal" data-backdrop="static">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myLargeModalLabel">TITULO</h4>
<button type="button" class="close" *ngIf="visible" (click)="close()">×</button>
</div>
Procedure
When you click on the edit icon in my list, nothing happens and when you open the browser console I see the error above. In mine module
, in providers
I tried to put the Renderer
, this message appears:
O tipo 'typeof Renderer' não pode ser atribuído ao tipo 'Provider'.
O tipo 'typeof Renderer' não pode ser atribuído ao tipo 'TypeProvider'.
Não é possível atribuir um tipo de construtor abstrato a um tipo de
construtor não abstrato
What modal framework are you trying to open? Bootstrap? Put html snippet or ts referring to modal
– veroneseComS
Use renderer2 the Nderer has already been deprecated
– Eduardo Vargas
then, but the error is precisely in the Remaster. And I tried to do with the Renderer2 too, from the same message
– LeoHenrique
see if the module you declared your component imports the commonsmodule
– Eduardo Vargas
This? import { Commonmodule } from '@angular/common';
– LeoHenrique
i have another Component/view that has does what I want, since yesterday I am comparing all the files between them and can not find what has different... Even uses the same module, this I posted is the edit, the modal I want I have in add
– LeoHenrique
I opened the modal Component and put the Editarcomponent in the Imports, created a property and called it and it worked....
– LeoHenrique
Hello @Leohenrique, Do not change the question title to indicate that your problem has been solved. You can answer your question and later accept the answer, it will help people with the same problem =D -- I can answer my own question?
– Icaro Martins
@Icaromartins Sorry... OK, I’ll take a look
– LeoHenrique
@Leohenrique, there is no need for an apology. = D - I only commented for you to know/understand why the reversal. And the
você pode responder sua pergunta
is information for if you wanted to leave your question as answered and help the community, you can also delete it if you wish. = D– Icaro Martins
Doubt @Icaromartins It is common for people to delete or auto reply when they themselves can solve?
– LeoHenrique
@Leohenrique, I would say that both are common and there is still a 3 option which is the question go unanswered. Sopt Model Encourages Self Responding.
– Icaro Martins
I would say that, if you have found the solution, the best thing is for you to answer, because then the content will be useful for other people who visit the site in the future (and who have the same problem). It is very frustrating when we find a link with the exact problem we are having, which says that the problem has been solved, but does not say how: https://xkcd.com/979/ :-)
– hkotsubo
@hkotsubo puts, real.. I’ve been right to life by finding the possible solution to my mistake, log on to the site and see that was not solved haha... All right then, I’ll post, I appreciate everyone’s feedback
– LeoHenrique