Questions tagged [angular-renderer]
11 questions
17
votes
2 answers
Difference between Renderer and ElementRef in angular 2
What is the difference between Renderer and ElementRef? In Angular both are used for DOM Manipulation. I am currently using ElementRef alone for writing Angular 2 directives. If I get more info about Renderer, I can use that in my future…

Niyaz
- 2,677
- 3
- 21
- 40
4
votes
2 answers
invokeElementMethod in Renderer2 angular
Context Angular project
I have the following snippet:
export class OnlyNumberDirective {
constructor(private _el: ElementRef,private renderer:Renderer2) {
}
@HostListener('input', ['$event']) onInputChange(e) {
…

Mostafa Saadatnia
- 802
- 8
- 20
3
votes
3 answers
Angular 2+ CSS Custom Properties (variables) with Renderer
I'm trying to convert Vanilla JavaScript code to Angular 2+.
In Javascript, I have a statement like this:
document.documentElement.style.setProperty(`--${cssVariableName}`, value);
In Angular, the only way I've found to replicate the above…

Link79097
- 68
- 3
- 6
3
votes
2 answers
Angular: Use Renderer 2 to Add CSS Variable
Is it possible to add inline style css variable using Renderer2?
I tried the following but it doesn't work.
import { Component, OnChanges, Output, ViewChild, Renderer2, ElementRef, ViewEncapsulation } from '@angular/core';
@Component({
})
export…

locnguyen
- 841
- 1
- 12
- 25
0
votes
0 answers
ng2-chart/chart.js Angular Doughnut chart label disappears when I switch between child components
I am using two child components inside a parent components these child component contains a Doughnut chart, and a Line chart. I have created label inside the doughnut chart using animation property of DoughnutChartOptions, but when I am switching…

Sanket
- 1
0
votes
1 answer
What is the best approach to render data in Angular?
I have multiple post data inside an array. I want to render each post.
There are two approaches to render :
1: create a reusable component and call it multiple times inside *ngFor

sanjay
- 514
- 2
- 5
- 14
0
votes
1 answer
Angular rerenders when user hovers over Openlayers map
I am using Openlayers 6 in my project alongside Angular 8.
And up until now i noticed that whenever i hover over Openlayers map, Angular component, where the map is located, gets re-rendered.
My question is how do i make parent component stop…

Mario Petrovic
- 7,500
- 14
- 42
- 62
0
votes
1 answer
Angular 6 How to add and remove class using Angular Renderer2
I am trying to use angular Renderer2 to add and remove a class in HTML template.
Here I am facing the difficulties:
to add the class once component will load
Only the selected item should have the class
I have created a demo in stackblitz. Please…

Md. Amanullah
- 311
- 4
- 15
0
votes
1 answer
Angular Renderer2 setStyle only if specific class present on host
I have a (spinner) directive that may add/remove a class (.spinner) using @HostBinding. It also adds/removes an img (spinner.gif) when activated.
If .spinner is present on the host, a bunch of styles defined in the scss file are applied:
.spinning…

kmansoor
- 4,265
- 9
- 52
- 95
0
votes
1 answer
Not updating the table data after inserting new record in angular 2
I am learning Angular 2. I am building a simple CRUD application using Angular 2. I am facing an issue, after inserting a record, the table is not refreshing in client side, however, it is inserting in the database. But if I reload the web page, it…

Bushan Sirgur
- 67
- 1
- 3
- 9
0
votes
1 answer
Append children to document.body angular way
I have written code like below
this._renderer.appendChild(document.body, form);
This works fine. But i am directly accessing document.body. Is there a angular 2/4 way of access document.body?

Hacker
- 7,798
- 19
- 84
- 154