Questions tagged parent-child

Explore the latest questions and answers asked by our top developers.

Angular switching between components and pass a value as well

I have a navigation page that has two options (let’s say finance and shipping) to go to next page which opens up either of the two main components. And each component has a list of orderId’s which when clicked gives details about either finance or shipping. Now, when I am on one of the main […]

By Zorro33
Published
Categorized as angular, components, parent-child Tagged , ,

In my child component , i want to get specific id details?

I have been struggling with since two days. Hopefully i will get solution Here. In my child component i want to get specific id details. but its not working, in url, i am able to pass id , but its displaying all id details. here is my code. ne-policy.html (parent) <div class="pb-3 pl-3" *ngFor="let product […]

By Mercy
Published
Categorized as angular, parent-child Tagged ,

JEST+ANGULAR Testing an @input() of a component

God day developers , I´m quite new about tests , thus in one of my basic implementations I´m trying to test this input in my nav-bar component , but for some reason i receive null. The design of my code for the child and parent components would be something like this: ===== child component HTML […]

By Enrique GF
Published
Categorized as angular, jestjs, parent-child, unit-testing Tagged , , ,

click event in parent of component not working in angular

I have nested component like this pattern <div (click)="saveInfo()"> <product-list-component> <single-product> <div (click)="navigateToDetailsProduct()"></div> <single-product> <product-list-component> </div> and I want when I click on single product both of click function (saveInfo() in parent and navigateToDetailsProduct() in child component) are executed. but sometimes both of them are executed and some times just a click function in child […]

Styling angular material components from child components

HomeComponent templates includes a router outlet /* home.component.ts */ … <mat-sidenav-container> <mat-sidenav-content> <router-outlet></router-outlet> </mat-sidenav-content> </mat-sidenav-container> that will render a ListComponent which style should set the overflow of mat-sidenav-content. Why is the following not working? /* list.component.css */ :host-context(mat-sidenav-content) { /* same for .mat-sidenav-content */ overflow: unset !important; } From my understanding the selector should pick […]

Angular – Control angular tab using dropdown option

Have created a tab component that allows the user to add multiple tabs and the individual tab information will get populated upon clicking the tab header which is working fine without any issue. I would like to control/Manage the tab click using the dropdown select options. stackblitz app.component.ts import { Component, ViewChild } from ‘@angular/core’; […]

How do I inject things into a parent class constructor even though I have to call super() in my Angular application?

I’m working with an Angular application and I’m trying to figure something out. I have this code here: export abstract class ListPageComponent { … constructor(protected ngZone: NgZone) {} … } export class UserListPageComponent extends ListPageComponent { … constructor(protected ngZone: NgZone) { super(ngZone); } … } The issue with this is that this creates two references […]

Is it wrong to use Subject observables to share data between parent and child components?

I usually use @Input/@Output directives to share data between components with parent/child relationship. But I can also use observables like BehaviorSubject to subscribe and listen to observers, so I am confused if I should use obserbvales when I can use @Input and @Output directives. Source: Angular Questions

By Ali Al Amine
Published
Categorized as angular, observable, parent-child Tagged , ,

Pass value from parent to child component not working

I have a drop down list on my parent component and when a user select a value, I want to pass that value to the child to be passed in another method call to the database. The issue is my value in the child is always undefined. parent.ts export class ReportsMainComponent implements OnInit { public […]

By JohnK
Published
Categorized as angular, parent-child Tagged ,

How to ask child component to access it’s html template and show something on UI from parent component using component’s class instance?

I am working on one project in which, I have 2 component : Main component, Popup component Main Component TS: popupCompo = new popupComponent(); onButtonClick() { popupCompo.showModal(); } popup Component TS : ==> HTML <ng-template #popup> … </ng-template> ==> TS : @Viewchild("popup") popupElement : Elementref; constructor(public modalService: NgbModalService) {} showModal() { console.log("popupElement", this.popupElement); // undefine […]

1 2 3 6

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq