Exception when trying to open modal

Asked

Viewed 67 times

-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

  • Use renderer2 the Nderer has already been deprecated

  • then, but the error is precisely in the Remaster. And I tried to do with the Renderer2 too, from the same message

  • see if the module you declared your component imports the commonsmodule

  • This? import { Commonmodule } from '@angular/common';

  • 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

  • I opened the modal Component and put the Editarcomponent in the Imports, created a property and called it and it worked....

  • 1

    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?

  • @Icaromartins Sorry... OK, I’ll take a look

  • 1

    @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

  • Doubt @Icaromartins It is common for people to delete or auto reply when they themselves can solve?

  • 1

    @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.

  • 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/ :-)

  • 1

    @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

Show 9 more comments

1 answer

0


I managed to do as follows, inside the Component of my modal, I saw that only with the import of the add Component as said in this comment:

eu tenho outro component/view que tem faz o q eu quero, desde ontem estou comparando todos os arquivos entre eles e nao consigo achar o que tem de diferente... Inclusive usa o mesmo module, este que postei é o editar, o modal que eu quero eu tenho no adicionar

Simply yes, I only did that, I imported the Editarcomponent and put as parameter of the constructor, this Component...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.