For this you have to use Global Service/shared Service , firslt set your global variable with value globaly in your app than you are able to use that service anywheer in your app.
let suppose this is our Global service
export class GlobalService {
array: string[];
}
export class HomePage {
array: any[] = [];
constructor(private global: GlobalService){
this.array = this.global.array;
}
}
export class SecondPage {
array: any[] = [];
constructor(private global: GlobalService){
this.array = this.global.array;
}
}
you can inject that GloablService globally in your app. like in the main module than no need to add service in the list of providers everytime.
just import this and intilize in the constructor and access their method and variables