Unable to retrieve values from an array using the TS code below:
this.dataservice.get("common/public/getAllCategories", null).subscribe(data => {
//console.log('categories'+JSON.stringify( data));
this.categoriesarray = data;
});
var data = this.items;
var categoriesdata = [];
for (var i = 0; i < data['categories'].length; i++) { // <- Error occurs on this line
categoriesdata.push(data['categories'][i].categoryID);
this.selspecialization = categoriesdata;
}
this.EditRequest = 'block';
}
Here is my HTML snippet:
<button type="button" *ngIf="!userRechargeTable" class=" smallbtns btn roundButton btn-theme blue" (click)="edit()">
Edit
</button>