Search code examples
angulartypescriptcomponentsprimengrenderer

Cannot import Renderer2 component in Angular.


I'm trying to import Renderer2 using:

import { Renderer2 } from '@angular/core';

However, I get the error

"Module '"project/node_modules/@angular/core/index"' has no exported member 'Renderer2'.

I'm unsure why this is happening. I'm using PrimeNG (here) which contains a component called ConfirmDialog which contains the same import statement, yet I don't run into any issues with it. I've seen posts that suggest Renderer2 is only compatible with Angular 4 - I'm currently using @angular/core 2.2.4. If Angular 4 is required, then shouldn't the ConfirmDialog of PrimeNG break (it doesn't)?


Solution

  • As you said that Renderer2 is only used in angular angular/core 4.x.x Project .If you upgraded the primeNG latest version "Sure Will not run according to the upgrading due to angular 4 version". So you need either Upgrade the project if you urgently need Renderer2. Instead you can use angular2 Renderer