Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
93 views

I have a directive that reads src attribute and appends a DynamicComponent. It also sets an input property of DynamicComponent. @Directive({ selector: '[appDynamic]' }) export class InjectDirective {...
sanjihan's user avatar
  • 6,138
0 votes
0 answers
43 views

I'm using Renderer2 to render some custom elements in an Angular application. As each element is created, it is stored as a constant: const myNewElement = this.renderer2.createElement('div'); When ...
Matt Saunders's user avatar
2 votes
1 answer
87 views

I am programmatically appending a new element to an existing element in my component, but the styles associated with the .target class defined in the component's styles do not appear to apply to the ...
D M's user avatar
  • 7,347
1 vote
2 answers
77 views

How can I remove the element that has the class loader? <ngx-supp> <div class="ngx-supp-class"> <div class="loader">...</div> <div class="...
akanzari's user avatar
  • 107
1 vote
1 answer
141 views

I am developing an application, in Angular 15, that displays a form for a dynamic query. I get the form parameters from the Backend. I get from back something like this { "codRespuesta": 0,...
Eduardo Mancilla's user avatar
1 vote
1 answer
177 views

I have an angular application angular-tour-of-heroes with the following structure: src ->app ->your-component ->your-component.component.html -&...
Kushagra Agarwal's user avatar
1 vote
1 answer
319 views

When I create a text node inside Angular with a sanitized string I unexpectedly got html entities in the output. I commonly sanitize all my input before using it inside the Renderer2. const text = '€£'...
Wilt's user avatar
  • 44.9k
0 votes
0 answers
155 views

I'm trying to add a click event to dynamically created components, but the renderer.listen function doesn't seem to be working as expected. Here's my code: updateCardTemplate(arr: CardData[]) { for (...
Conta's user avatar
  • 184
0 votes
2 answers
364 views

I am currently making and operating the web using the angular 11 version. For page data analysis, I had to add marketing-related scripts to the head. When I searched it, I found out that I could add ...
BrownLee's user avatar
0 votes
3 answers
2k views

Here's my code: @Directive({ selector: '[appDropdown]', }) export class DropdownDirective { isClassApplied: boolean; @Input('appDropdown') className: string; constructor(private renderer: ...
Shubham Maheshwari's user avatar
0 votes
1 answer
593 views

Good morning, I am having a problem with viewchild which cannot find my selector in my html code. The goal is to look for my 'field' selector in my html to clone it and add a new class to it each time ...
Abate Raphael's user avatar
4 votes
2 answers
3k views

I'm trying to create a carousel component that has n amount of child components based on whatever size list it will get. I want the parent (carousel) to control the styling for children as it ...
lowkey's user avatar
  • 90
2 votes
1 answer
544 views

I am trying to create a custom directive that will allow me to read a template from a json / ts object and insert it in my directive template. For example, in a config file / database / ts file, I ...
Jeff's user avatar
  • 4,473
1 vote
2 answers
961 views

I have two HTML elements below, <p #test>with reference</p> <p id="with-id">need to access without template reference</p> I know I can access the first P element ...
anonymous's user avatar
  • 1,731
0 votes
0 answers
62 views

When some data arrives from an API I need to perform a click event in my Angular app. It has to be done from typescript code. I use a component from an external library and it is the only way to make ...
thortineoc's user avatar
1 vote
1 answer
1k views

I am using angular 10 and using Renderer2 to add and remove classes: this.renderer.removeClass(this.document.body, 'signin-user'); this.renderer.addClass(this.document.body, 'anonymous-user'); Does ...
Yogesh's user avatar
  • 344
0 votes
1 answer
945 views

I have a directive that replaces a table value with an "a href" using renderer.setProperty. Attached to the "a href" is a "click" property which im not sure how to access ...
hello world's user avatar
0 votes
2 answers
1k views

Currently I have an Angular component that appends a list of script tags into the DOM with Renderer2 library, the code of these scripts is retrieved from an external source. In the following snippet, ...
Across's user avatar
  • 63
0 votes
1 answer
1k views

I manually add and remove Eventlisteners on DOM-Elements for performance reasons from the ngZone in Angular. My implementation seems fine and I'm currently try to refactor code to keep it DRY and more ...
thilopuetz's user avatar
2 votes
0 answers
980 views

Is there any difference in these two methods of accessing native element from security perspective? SomeDirective implements OnInit{ constructor( elementRef : ElementRef, renderer : ...
IdoAmar's user avatar
  • 21
3 votes
2 answers
6k views

I have a directive that implements a slider when you hover the element, If you visit this site when you hover the image the directive makes other images absolute to the main one and enables arrows for ...
Behnam Aminazad's user avatar
0 votes
0 answers
428 views

When reading documentation of Angular I found an information stating that DOM Elements should be altered by the Renderer2 class. I tried to update my project where I used ViewChild directive, but this ...
Kajetanoss's user avatar
0 votes
0 answers
2k views

i'm learning Angular, and i have an issue with renderer2, it seems the get is working fine and he gets to the function styleChoice with the right informations but the setStyle isn't working with the ...
Flairsus's user avatar
0 votes
1 answer
361 views

Description I want to create and control a Material ProgressBar from within a directive. Problem I can't update the ProgressBar's value property (though everything else, for example the mode). ...
ddhille's user avatar
  • 157
0 votes
1 answer
2k views

I want to dynamically create an element and then get its clientWidth. The code snippet looks like this using the regular DOM API. HTML Snippet: <div id="non-existent-element"></div&...
Eddie Lam's user avatar
  • 629
0 votes
1 answer
472 views

I am trying to use ViewChild like this: @ViewChild('hello', { static: false }) divHello?: ElementRef; This is the template: <div class="wrap" #hello> Some test data </div> But,...
joler-botol's user avatar
0 votes
2 answers
1k views

How do I render an SVG (which I have locally stored in my project) using Renderer2 in Angular? I tried doing it like following: const div = this.renderer.createElement('div'); const svg = this....
Karan Budhwani's user avatar
1 vote
1 answer
522 views

I have a directive that uses Element Ref and Renderer 2 to style the element. I wanted to know how can I style placeholder using renderer or any other way in this directive. Code TextSizeDirective.ts ...
manu george's user avatar
0 votes
1 answer
2k views

I am trying to create a chat-based application where I am creating each type of chat popup according to requirements and using Angular Renderer2. I tried to add a (click) attribute to the chat message ...
Bharat Dhal's user avatar
0 votes
0 answers
352 views

I want to put the attribute "required" dynamically on an input text field using Renderer2. The attribute is added, but the field doesn't turn to invalid when the field is empty. I tried ...
doinel's user avatar
  • 97
1 vote
1 answer
602 views

I'm creating angular client using Chime JS SDK. I'm able to create meeting and add attendees to the meeting. However there is no clear documentation on how to bind video tiles to UI on Angular. I'm ...
Chandra Eskay's user avatar
1 vote
1 answer
166 views

I am having trouble getting the correct values for a small custom context menu. When setting the styles via ngStyle. When doing it like below the componen will be rendered correctly, but the console....
denns's user avatar
  • 1,151
0 votes
1 answer
3k views

I would like to use a mat-slider with a thumblabel that doesn't move along with the slider when it is moved. The way I see it the entire 'mat-slider-thumb-container' gets moved along the slider with ...
Anbesa's user avatar
  • 131
0 votes
0 answers
1k views

I create a new element in the DOM with const newTag = this.renderer2.createElement('g', 'http://www.w3.org/2000/svg'); Then I would like to add a bind attribute with this.renderer2.setProperty(newTag, ...
mtnp's user avatar
  • 419
0 votes
1 answer
2k views

I am trying to select all pre elements in an angular component AFTER the document has been loaded. ngAFterViewChecked, ngAfterContentChecked, ngAfterContentInit basically run 30 times before the ...
Jonathan's user avatar
  • 4,135
3 votes
1 answer
3k views

I have a button like below which opens a modal when I press "space" <button type="button" (keydown.space)="openLg()" class="btn btn-link"></button> ...
Shuvo Barua's user avatar
0 votes
1 answer
728 views

Angular's renderer2 will not apply linear-gradient CSS. Can anyone see what I'm missing? export class AppComponent implements OnInit { constructor(private renderer: Renderer2, private elementRef: ...
Ben Racicot's user avatar
  • 6,048
0 votes
1 answer
2k views

I have found an example online of a Tooltip directive. I need to expand it so I can pass data to the tooltip and render it in an *ngFor. So far I have app.component.html <div tooltipDirective [...
Bwizard's user avatar
  • 1,025
2 votes
4 answers
8k views

How can I add separate CSS for one page in Angular? I've discounted both of the standard solutions to this problem: Using ::ng-deep or ViewEncapsulation.None. CSS added in this way won't be removed ...
Eliezer Berlin's user avatar
2 votes
1 answer
3k views

I want to append new child node after the parent node but appendChild appends it inside of it. Here is what I have: My component.html: <div id="parent" (click)="appendChild()"&...
cheshire's user avatar
  • 1,159
2 votes
2 answers
2k views

Inside app component import { Component, ViewChild, Renderer2, ElementRef } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app....
user avatar
0 votes
1 answer
1k views

I migrated an project from Angular 7 to 8 and I had to change the Renderer class to Renderer2 and I am facing the following error: ERROR Error: Template error: Can't bind to 'disabled' since it isn't ...
emarzo's user avatar
  • 65
1 vote
1 answer
1k views

I have a preferences service in an angular 9 application that create a script tag it use 'createElement' From Renderer2. When I try to mock the Renderer2 the createElement is not recognized. This my ...
Amirak's user avatar
  • 73
0 votes
1 answer
1k views

I need to add a div with class '.cart-list-value .delete-product', that contains a background image, to all elements that have the class .cart-list-item. I was able to get all the elements with class ....
VictorE23's user avatar
0 votes
1 answer
476 views

I have the following code for opening and closing a slide menu for each row in the table. The <td> is as shown below: <td class="rm-release_table-cell" *ngIf="settings.actions&...
Happy Coder's user avatar
  • 4,802
1 vote
1 answer
2k views

I have a method that gets invoked based on certain user action. In that method I am trying to download a file using this approach. But I don't want to use/refer document object directly so I am using ...
Aakash Goplani's user avatar
3 votes
2 answers
7k views

When trying to create a tab component using Renderer2 to select a tab element, and try to add some css class to change color for example for selected tab that is currently not selected, the HTML ...
HDJEMAI's user avatar
  • 9,848
1 vote
2 answers
4k views

In an Angular application let's suppose we have a body element as <body> ... </body> and now I want to set its background to some value using Angular Renderer2 as this.renderer....
0x1211's user avatar
  • 225
1 vote
1 answer
609 views

I'm working on this and can't think of a way to handle the error thrown by renderer2.selectRootElement. This is what my function looks like: private doSomeAnimation(){ const modalWrapper = this....
HenryDev's user avatar
  • 5,013
2 votes
2 answers
3k views

So I have an input field which I would like to focus on load in an Angular application. I read that the Renderer2 way is the good method of doing so, and it works if I call the function for example on ...
Smithy's user avatar
  • 847