I am trying to show the list of values in MatBottomSheet from another component. I am always getting error like below.
ERROR TypeError: Cannot read property 'id' of null
I am passing values from testcomponent like below:
openBottomSheet(order) { const id = order; console.log('====>' + JSON.stringify(id)); console.log('====>' + JSON.stringify(order)); const MatBottomSheetRef = this._bottomSheet.open(ProductbottomComponent, { data: id, }); this._bottomSheet.open(ProductbottomComponent); } And calling above component to another ProductbottomComponent typescript is
ngOnInit() { this.http.get('/api/getorder/' + this.authService.namespace + '/' + this.data.id) .subscribe(result => { this.model = result; console.log('-====>' + JSON.stringify(this.model)); }); } productbottom.component.html (here is a part of my template)
<table cellpadding="10" width="100%"> <thead> <tr style="text-align:left"> <th>Item</th> <th>Qty</th> </tr> <tr *ngFor="let del of model.products"> <td>{{del.name}}</td> <td>{{del.quantity}}</td> </tr> </thead> </table> Getting values in console log
{"id":"0504fd10-1278-41bf-b052-a459c1e37998","products":[{"productid":"","name":"Snowball","price":"5.00","quantity":1}],"order":"Order - 1005","name":"test123","email":"[email protected]","mobile":"111111111","status":"Packing In Progress","note":"","packedby":"test78","packedbyId":"1bd9632a-406a-4212-a8c0-d0732ab42635","packeddate":"","deliveredby":"","deliveredbyId":"","delivereddate":"","type":"testPickup","address1":"","address2":"","city":"","state":"","zip":"","createddate":"2020-07-06 22:07:17","lastModifieddate":"2020-07-06 22:07:17"} Help me to fix it!



this.dataseems to be null. Where is it initialized? How do you callngOnInit()? As this is not an arrow function, did you think of binding it?