My Ionic page involves passing an array of objects to my Modal page:
export class SelectAddress{
constructor(
public id : string,
public number : string,
public line1 : string,
public postcode: string
){}
}
I tried to achieve this by using the following code on my Ionic page:
let modal = this.modalControl.create(SelectAddressPage, {addresses: this.addressResult as Array<SelectAddress>});
modal.present();
Upon trying to retrieve the data on the Modal, I encountered an issue with the following code:
constructor(
public platform: Platform,
public params: NavParams,
public viewCtrl: ViewController) {
this.addresses = params.get('addresses') as Array<SelectAddress>;
When attempting to loop through the results, an error message appeared:
Uncaught (in promise): Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays. Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
It seems that while primitive data types like integers and strings can be sent successfully, more complex types encounter issues in this process.
Initially, I tried injecting AddressService in my ModalControl to retrieve the data, but the dependency injector failed to do so.
Do you have any suggestions on sending complex types via navParams or should I explore alternative options?