I am trying to pass values from one component to other components, so far i have refereed some tuts and created my code but still facing issue.
I have following code in my SelectComponent.ts
export class SelectComponent implements OnInit {
user: LoginUser
selectLicences = [
{ name: 'Control', id: 1, isChecked: false, quantity: 1 },
{ name: 'Complete', id: 2, isChecked: false, quantity: 1 },
]
ControlQuantity=10
CompleteQuantity=20
i want to access ControlQuantity and CompleteQuanitiy in my other "buyerComponent"
here is buyerComponent.ts
export class BuyerComponent implements OnInit, OnDestroy,AfterViewInit {
@ViewChild('selectProducts', { read: SelectComponent, static: false })
selectProducts: SelectComponent
CompleteQuantity:number
ControlQuantity:number
ngOnInit() {
this.CompleteQuantity=this.selectProducts.CompleteQuantity
this.ControlQuantity=this.selectProducts.ControlQuantitity
}
}
stackblitz link: https://stackblitz.com/edit/angular-ivy-umje3g?
selectProducts?, what is the relationship between the components?, Please refer this video you will get idea@ViewChildas much as possible. It's not fit for unit-testing