Questions tagged [viewchild]

ViewChild is a decorator for Angular component variables, which allow to bind a template element.

ViewChild is a decorator for Angular component variables, which allow to bind a template element. Official Angular documentation here: https://angular.io/api/core/ViewChild.

437 questions
0
votes
1 answer

Passing data to a dynamic component loader using a service in Angular

I have a dynamic component loader, and I need to pass in data through a service. I can get the data to display if I fire the function on click for example, but not OnInit. I have tried using AfterViewInit Eventually the data will be coming from an…
Wayne
  • 146
  • 3
  • 13
0
votes
1 answer

Angular DOM Manipulation: Why ViewChildren works and ViewChild doesn't

I found an interesting article here by ngWizard that references a stackblitz example on the correct way to delete a component. @Component({ selector: 'app-root', template: `
Skyler
  • 777
  • 1
  • 9
  • 34
0
votes
1 answer

Angular use $event.target or ViewChild...is there a difference?

I frequently find myself wanting to disable a button once it has been pressed on a form. So I do something like this:
Gargoyle
  • 9,590
  • 16
  • 80
  • 145
0
votes
1 answer

Cannot retrieve width and height of an element through ViewChild like other answers here do?

So I've got an Angular component, the HTML of which before the typescript gets involved is simply: In an attempt to make a responsive webpage featuring a line chart, I decided to set the height and width with…
0
votes
1 answer

What is use of @ViewChild if we cannot change properties or manipulate them from Parent Component?

I got 2 components - home & about. In both I inject a third (child) compnonent - hearts. Now I am manipulation the value of 'age' property in hearts (set to default as '23') using @viewChild from 'home component'. I see that value seems changed in…
Deadpool
  • 7,811
  • 9
  • 44
  • 88
0
votes
1 answer

Accessing and interacting with child elements with Angular 6

I am having an issue accessing a child element with Angular 6 material application. I have a header component that has two child components, app-header and app-sidenav. The header.component.html has the following code:
realnsleo
  • 709
  • 2
  • 12
  • 29
0
votes
1 answer

Cannot read property 'nativeElement' of undefined @viewchild

here is the scenario, i have main file tabs component where i have included text component using @ViewChild(); now on ngAfterViewInit() i am initializing menu and list of submenu. and as soon as i am done creating list of submenu i want to assign…
0
votes
1 answer

getData from multiple filters does not return anything

I can't get my getData function on app.component.ts to return the query with all the arguments for the API Request. I don't get any errors and I also can't console.log inside the function because it doesn't work. It skips everything I write inside…
0
votes
0 answers

dynamically adding # attribute in angular 6 element

I have following code in one of my templates:
Tejashri Patange
  • 329
  • 2
  • 6
  • 24
0
votes
2 answers

Angular Child Component is not being updated inmediatly

I'm learning Angular 6, I tought I was doing it right, but I'm facing a "problem-doubt" I have a parent and a Child: My parent is sharing info to my child by using input binding A button trigger a function where the info is updated Inmediatly,…
WindSaber
  • 323
  • 1
  • 3
  • 15
0
votes
1 answer

Read an input with viewChild

I have an input (type file) that I have to read. My client must choose a 640x480 24-bit BMP file. I know it is possible to verify this in the header but I'm not able to read the data of the file. What can I do to get access to the data so I could…
Daniel
  • 77
  • 1
  • 2
  • 10
0
votes
1 answer

How to access the content of a template within ng-template using template reference variable

I want to know if it is possible to access a template component within ng-template using a template reference variable? I have tried using @ViewChild and @ContentChild but none of them seems to work Example: I want to have access to contents of…
Arthur Decker
  • 1,191
  • 3
  • 15
  • 45
0
votes
0 answers

How to mock @viewchild in angular test case

I am trying to mock viewchild in my angular test cases. I tried to use fixture.componentInstance, it doesn't work. How to mock @ViewChild in angular 4 test cases. export class AA{ @ViewChild('view') testView; }
user1015388
  • 1,283
  • 4
  • 25
  • 45
0
votes
2 answers

Form ViewChild is not getting input field value in component

Code explains the issue. I am not able to use #myForm to access input field validation from controller using ViewChild this.myForm.name
...
.... …
Siddharth
  • 213
  • 5
  • 14
0
votes
2 answers

Ionic 3 - How to redirect roottab when opening app

I'm new in angular and ionic and I have a problem that pissed me off. I m sure the solution is simple but I after lot of searches and tries I don't find my solution. I dev an app using Ionic 3 and use phonegap push plugin to handle apple…
user7430961
  • 35
  • 1
  • 6