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

Angular 8: using ViewChild get a method result from a child to parent after that method is invoked in child component

In my child component i have two buttons like following: child-component.html
In child-component.ts: export class ChildComponent…
Nazem Mahmud Piash
  • 1,053
  • 1
  • 13
  • 34
0
votes
2 answers

view child component undefined

I have a parent component(DepotSelectionComponent) and a child component(SiteDetailsComponent). An event(moreDetails) is emitted to the parent component. This event then calls the getDetailsPage()function within the parent, which changes the page…
ashley g
  • 857
  • 3
  • 11
  • 21
0
votes
1 answer

Angular - Function linked to ViewChild executing twice

I have three components, Nav, App, Form. In the Nav component I have a function that changes the position of CSS, I can call this function from Nav and App Component (Gets a trigger from Form Component). My problem is that when I call the function…
0
votes
1 answer

Access child component data from parent component

I have a list in the child component. I want to access this list from the parent component (AppComponent) and display it using @ViewChild decorator, but the list is always undefined in the parent component export class CategorieComponent implements…
G.AOUDIA
  • 15
  • 7
0
votes
1 answer

Setting nativeElement.style.color in ngAfterInit doesn't work in Angular

I am learning Angular and just run in a strange issue. When I set the nativeElement.style.color to red the Plot text only becomes red when I remove the img tag that is above.. Seems that it is a loading issue? But I used ngAfterViewInit() to color…
JeR
  • 1
  • 4
0
votes
1 answer

InnerHtml of elementRef of component created dynamically by componentFacory not containing binded values

I have a simple component named component1: This is its HTML with the bindings and with the template reference:
{{someNumber}}
This is…
Guy E
  • 1,775
  • 2
  • 27
  • 55
0
votes
1 answer

AngularEditor: ViewChild removed after successful file upload?

I would like to use https://github.com/kolkov/angular-editor, but there is a problem: I want to upload images, this seems to work fine, request to/from backend looks good. There is an ElementRef myInputFile: myInputFile: [{ type:…
0
votes
1 answer

Call a method in the nested component

I have two components (1-app-student-list 2-app-student-detail). I want to use student-detail in the student-list like the following : app-student-detail.html

Student Detail Component is here ....

app-student-detail.ts export class…
user11912021
0
votes
0 answers

Closing angular dropdown on submitting form inside it

I have a dropdown menu containing a form. I want to close the dropdown whenever Ok is clicked, that is whenever the form is submitted. Right now it remains open. Would prefer not to use javascript or jquery
0
votes
1 answer

ViewChild can't pull directive from button

when accessed via: ngOnInit(): void { this.initalFocusButton.focus(); // undefined unless it's an ElementRef } comes up undefined in OnInit and AfterViewInit(ng8 so it doesn't matter). I've…
Anthony
  • 7,638
  • 3
  • 38
  • 71
0
votes
2 answers

Problems with @ViewChild

I am currently creating a @viewChild component, tabs in my app. However, upon inserting the following lines: @ViewChild('tabs') tabs: IonTabs; I am facing an error 'Expected 2 arguments, but got 1.' Please helps. Thks!
speedie
  • 82
  • 10
0
votes
2 answers

Update slider component data from any other component

I'm new on Angular, I have a slider component, but I'll use this in 2 pages (homepage, news), I'm using ViewChild to call it from parent (homepage) and want to add new images and title to each slide, both pages (homepage, news) have same slider…
0
votes
2 answers

RecyclerAdapter - can't set long & normal click listeners to parent and child

I have a simple RecyclerView with a row item containing one image. I want to set a normal onClickListener to the ImageView and a longClickListener to the itemView itself. The issue is that when doing so - they can't seem to live together with each…
0
votes
2 answers

Why does @ViewChildren pick the template only for the first time?

I am creating an app where I want to render the buttons inside a table using a component. So, I created a component where I'v kept the button template and am using @ViewChildren to get the template and ViewContainerRef to apply the component to the…
testacc
  • 135
  • 2
  • 12
0
votes
0 answers

Unit testing angular service, Injecting dependencies through beforeeach doesn't get executed

I am trying to unit test a component that has a @viewChild component and few more services. Following is my spec.ts file. beforeEach(() => { TestBed.configureTestingModule({ declarations: [ UpStoryComponent,ExperienceListComponent,…