Questions tagged [elementref]

Reference

78 questions
1
vote
1 answer

If statement and ElementRef to change background color not working [Angular]

I'm trying to get the background of the text to be green if case 3 and "Accepted your offer" is printed. I want to use elementRef to access the DOM and javascript to add the background colour using if statement. I added the if statement at the back…
user14526302
1
vote
1 answer

How to use DOM click() in Angular using Renderer2

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 combination of Renderer2 and ElementRef. This is…
Aakash Goplani
  • 1,150
  • 1
  • 19
  • 36
1
vote
1 answer

Why cant @ViewChild run outside AfterViewInit?

so I am trying to do some events base on the scrolling of my Angular application. I have a problem since I am trying to access a element in my HTML with the help of @ViewChild. I can access the element inside ngAfterViewInit() but I can't access it…
Allamo Olsson
  • 299
  • 2
  • 12
1
vote
1 answer

Angular - Append dropdown to div

I am trying to add dropdown to a div. The html code (dropdown is an example) is dynamic code. Even though on clicking it shows the dropdown button but the dropdown isn't working. Following is my code from component file import { Component, OnInit,…
Saad Bashir
  • 4,341
  • 8
  • 30
  • 60
1
vote
1 answer

Angular: why value changes (using renderer2) doesn't trigger the events bind to that

Scenario: check this stackblitz when i change the input value by typing something, the (keyup), (change) and (ngModelChange) events all fire; when i change the input value by renderer2, none of the events fire what i want: I want to…
Akber Iqbal
  • 14,487
  • 12
  • 48
  • 70
1
vote
1 answer

Access value of a hidden div from inside an angular app in an iframe

I need to get a value of strings in a hidden div from inside an angular app. Here is what I have: