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

Setting properties on @ViewChildren in Angular

In my html template I'm having multiple elements generated by *ngFor. I am successfully able to subscribe to their value changes in the ngAfterViewInit lifecycle hook. However, I am not able to set the .checked property via code. Does somebody…
baouss
  • 1,312
  • 1
  • 22
  • 52
0
votes
1 answer

access to child elements

I think the only way to do this is a service, but I would like to know if any other way is possible. Parent:

Parent title

Child:
cucuru
  • 3,456
  • 8
  • 40
  • 74
0
votes
1 answer

how to make the focus on the different text boxes in angular 2

I have more than 25 text boxes and I need to make the focus on each text boxes based on the user input. But I don't want to make 25 different reference variables in my HTML also it will affect my angular code being more length. I am using…
shajan
  • 610
  • 6
  • 11
0
votes
1 answer

Angular 2+ How to get the Pixel Width of a div at run time

The div looks like this:
The container is a flexbox row if that matters that contains elements; I need to know if a new element I'm adding to the row is going to fit without causing a wrap. Thus, my code will sum up…
Yogi Bear
  • 943
  • 2
  • 16
  • 32
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
0 answers

Why is property not defined in angular using @ViewChild

This is my component from where i'm trying to access a variable in a child component. The parent is the app component and the child is called LoginComponent import { AfterViewInit, ViewChild } from '@angular/core'; import { Component } from…
Santi
  • 1,682
  • 1
  • 13
  • 14
0
votes
2 answers

ViewChild returns undefined

I am using material design and Angular 5. I was trying to use the material loader, so when navigation start show loader and when ends remove loader as per the answer in this question. I tried viewchild by
chewi
  • 159
  • 2
  • 3
  • 16
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
0
votes
1 answer

Instantiate several times a @ViewChild so i can use the HTML again Angular 4

I'm trying to call several times the component HTML but without including again the child component in the father component. I need it to be like this:
0
votes
2 answers

How to simulate a click on a ion-tab

I designed an element on the main page of my app that, when clicked, changes the active tab. I used to do the following: events.subscribe('change-tab', (tab, filterOnSport) => { console.log('TabsPage#constructor - change-tab event received…
Manuel RODRIGUEZ
  • 2,131
  • 3
  • 25
  • 53
0
votes
1 answer

Angular 2 shared component with component as attributes

I have a shared Component that can show a toggle button, this toggle button let you switch between two childs components, this two components must be passed as input from the parents that call the SharedComponent. Please any idea ?
0
votes
3 answers

Selecting viewchild with 1 hash selection in angular 2

Is there a trick to select multiple tag within same level with same tag?
It's always given "Reference "#el" is defined several times" error message. Thanks in advance
user5436320
  • 133
  • 2
  • 17
0
votes
0 answers

Angular 2 Only define ViewChild if *ngIf evaluates true

How can I only define a view child if it exists in template. I'm using a dynamic component loader like this ... viewContainer.directive.ts @Directive({ selector: '[viewContainer]' }) export class ViewContainer { constructor(public…
Max Solid
  • 1,213
  • 3
  • 21
  • 32
0
votes
3 answers

Access children's properties of a component in Angular 2

I'm working with Angular 2 and Ionic 2 and I would like to get a property from a parent component. So my parent composent is a class named "ServicesPage", and my child component is named "AddonCell". ServicesPage.html
iStornZ
  • 603
  • 1
  • 8
  • 19
0
votes
1 answer

Passing information from 2 children component to the parent component

I have a parent component(A) and 2 children components(B,C). The parent component contains the basic layout of the page, which doesn't change across all the layouts. I need to swap the contents in the middle of the page when the user select…
Matt-pow
  • 946
  • 4
  • 18
  • 31