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

Ionic 3 view child scroll event listener won't execute when the page is loaded

I used a ViewChild using Slides in put the in my element inside a . Now when the page entered or loaded I want to know the scrollTop position of that scroll even the page is loaded. Here is the sample of my code below in my…
KnowledgeSeeker
  • 1,058
  • 2
  • 19
  • 44
0
votes
2 answers

Cannot read property 'nativeElement' of undefined (Ionic 3 & Angular 5)

I have a problem using @ViewChild() on my Ionic 3 application. Indeed, I would like to be able to display a map on the second segment of my page. And I have the following mistake: ERROR TypeError: Cannot read property 'nativeElement' of…
0
votes
1 answer

Angular 4 get [routerLink] ViewChildren

I'm trying to get a list of all links in my current component, with a template looking something along the lines of this: I tried to set up an…
Cabadath
  • 897
  • 3
  • 13
  • 23
0
votes
1 answer

Child To Parent Value access using ViewChild

I have read about articles in angular6, 3 ways to communicate in child to parent.if its wrong,please demonstrate if possible 1)output emitter 2)using viewchild 3)shared Service. So here i need to understand how to communicate the viewchild from…
0
votes
0 answers

Access ViewChild i:e element Reference of a dynamically created Element in Angular?

I am Creating a iframe Dynamically in Angular in ngOninit. ngOnInit(){ const el = document.createElement('iframe'); el.setAttribute('sandbox', ''); } And then using ElementRef in ngAfterViewInit i am trying to access the…
INFOSYS
  • 1,465
  • 9
  • 23
  • 50
0
votes
1 answer

ViewChild binding with compiler checking

I use ViewChild in the following way: @Component({ selector: 'demo', template: `` }) export class DemoComponent { public firstname: string; @ViewChild('firstnameCtrl')…
Martin Schagerl
  • 583
  • 1
  • 7
  • 19
0
votes
0 answers

How to toggle a specific panel in an ngFor from the component.ts in angular2

A similar question was answered, but I cannot find out why the code is not working for me. I have a list of ngbpanels generated using ngFor. I need to expand/de-expand a specific panel according to some logic In the html file
Donia Zaela
  • 317
  • 1
  • 4
  • 15
0
votes
0 answers

@ViewChild and @ViewChildren Always Return Undefined, Even when no *ngIf is used

I am having trouble referencing a child component in a larger project so I dropped these into the project just for my own sanity check. In any instance @ViewChild AND @ViewChildren ALWAYS return undefined. What I need is to get the position and…
GRowing
  • 4,629
  • 13
  • 52
  • 75
0
votes
1 answer

Cannot read property 'form' of undefined angular 5

I have the following html form in angular
user9487981
0
votes
1 answer

Angular View variable not being updated when using ViewChildren

I am trying to implement some commenting functionality, and I have ran into a problem where the view value is not getting updated when values changes are being made to component. Let me explain in detail. I need to know if the comment I am dealing…
Tom O'Brien
  • 1,741
  • 9
  • 45
  • 73
0
votes
2 answers

Angular 4: Viewchild set focus

I'm trying to control the button focus without using the tag autofocus=true, but it seems that doesn't work properly, do you think is necessary a pipe?
Gelso77
  • 1,763
  • 6
  • 30
  • 47
0
votes
1 answer

viewChildren with directive

I want to add a directive and use viewChildren for identify them: // directive.ts @Directive({ selector: '[myOwnDirective]' }) export class MyOwnDirective { constructor() { console.log("hi") //never printed } } //component…
cucuru
  • 3,456
  • 8
  • 40
  • 74
0
votes
0 answers

View child component in dynamically invoking component

I have component that is invoking in router-outlet from other component. On view this component appears as pop up. In this component I have child component which is accessible by View child. The problem is - when I try to invoke child component…
0
votes
0 answers

Get view height and element height offset without using window or DOM

I’d like to get the view height without using window or document. I’d also like to get the distance between the top of an element and the top of the view height without using document at all! I am using Angular 4 to set the height of elements based…
skyleguy
  • 979
  • 3
  • 19
  • 35
0
votes
1 answer

Change input value from parent component Angular?

I need to change input value for custom value every time I am clicking out of the input. Here is code. I tried it with @ViewChild, but it works only first time. If I paste something after the first click out of the component - value doesn't change…
mr__brainwash
  • 1,334
  • 3
  • 16
  • 40