Questions tagged [elementref]

Reference

78 questions
0
votes
2 answers

Angular - Focus on input with dynamic IDs on click

*There are a lot of similar questions but I have not found a true duplicate that answers my question Apologies if I missed something. I have a page with several inputs/buttons (The same component repeated) and need to focus on the correct input…
user3390251
  • 317
  • 2
  • 5
  • 22
0
votes
0 answers

Want a directive for numbers in Angular2+ which takes only number and not using ElementRef

I am working in a project in Angular where there are many textboxes and I have to restrict the user to take only numbers ,I don't want to use any Javascript/Jquery code in Angular and wanted to use only Angular things so I created a directive but…
Code_1993
  • 127
  • 1
  • 4
  • 16
0
votes
0 answers

How can I use ElementRef instead of document.getElementById to fetch the nodeList

Currently I am using document.getElementById to fetch the exact checkbox that needs to be checked. Here is the code: setTimeout(function () { this.tradeids = JSON.parse(sessionStorage.getItem('tradeids')); …
Pratyush Swain
  • 144
  • 1
  • 9
0
votes
2 answers

angular2 get elementRef of component that is not a child

In my app I have following structure:
In header I want to add scrolling to specific component of main. My scrolling method takes as argument elementRef. But I can't get one by…
0
votes
1 answer

Compare HTMLElement with ElementRef

I am working in angular 5. I am invoking a function on keyup and passing an event to it. I also have another reference like this @ViewChildren('list') list: QueryList; I am trying to check their ids and based on that do something. But…
dhamchan
  • 15
  • 1
  • 7
0
votes
0 answers

generic type ElementRef requires 2 type arguments angular 6

I am using ElementRef to access DOM elements, but I am getting an error, generic type ElementRef requires 2 type arguments angular 6 This is code Import import { Component, OnInit, Input, ElementRef, Renderer2, AfterViewInit, ViewChild,…
mano10
  • 419
  • 1
  • 5
  • 17
0
votes
1 answer

How to Apply styled using Renderer2 to a child node of ElementRef -> nativeElement in Angular

Suppose I have the following Angular Template:

{{ someBinding2 }}

Arjun Panicker
  • 730
  • 1
  • 8
  • 20
0
votes
1 answer

How to set style of sub header using render2 in ionic?

I want to hide header and sub header of my application separately according to scrolled pixel amount. This is my home.html file:
0
votes
1 answer

Angular - How to access the nativeElement in click handler

Maybe only a "stylish" but nonetheless... I've the following which is working: // Template
. . .
user4096537
0
votes
1 answer

Creating angular directive, how do I get list item's attribute values from ElementRef? Angular 5

I have a typical navbar with a list of links. I am trying to clean the HTML for the navbar by creating a simple angular directive ('authorize') as shown in the HTML snippet below, but to do this I need my Directive to be able to receive the value…
0
votes
1 answer

Add Attribute to multiple subcomponent Tags

I use Alfresco ADF, which uses Material Design. They have a datatable Component, which in fact uses the the Angular Material Table. Now in order to implement a drag and drop feature, I need to add draggable="true" on every mat-rowtag. How do I…
user5417542
  • 3,146
  • 6
  • 29
  • 50
0
votes
2 answers

how to know elementRef who generates event

I have same listener for different inputs. When listener is fired, I can't get who generates the event.
cucuru
  • 3,456
  • 8
  • 40
  • 74
0
votes
1 answer

Add a class in all the elements of selector get by class in angular2

I am getting a element ref by below code and I want add a class and remove a class from all the elements which i get. app.component.html
0
votes
2 answers

Content of component in Angular? content

How do I get the contents of my current component? Say I have FooComponent that's used in another component, like so: bar How do I extract bar in FooComponent? Tried this, but got val = null: ngAfterViewInit() { console.info('val =',…
A T
  • 13,008
  • 21
  • 97
  • 158
0
votes
1 answer

How To Transverse/Manipulate the DOM in Angular 4

I am looking for how to access a DOM element in A4. I am having a hard time trying to wrap my head around this... I've been reading about ElementRef, ViewChild, etc... but I still don't fully understand how to transverse the DOM elements in Angular…
RooksStrife
  • 1,647
  • 3
  • 22
  • 54