I’m a newbies of ionic and angularjs。How can I can’t a the data of other PAGEs?
- router parameters?
- state Management, like vuex in Vue?
- local storage?
- or something else?
I’m a newbies of ionic and angularjs。How can I can’t a the data of other PAGEs?
I don’t think “accessing the data of another page” is a very helpful way of thinking in Angular. If you want to share data amongst multiple pages, create a service provider, store it there, and inject that provider in every involved page.
Thanks for your answer. I found that ‘NavParams’ is what I want…
I would agree use a service provider and not NavParams.
@rapropos Don’t you just love it - you provide excellent advice and it just gets ignored!
sorry for that …
@navych2020 I apologise if my remark offend you.
It was not aimed at you personally but on the excellent advice that @rapropos provides free of charge.
ok, let’s forget it.
@JAR19 @rapropos Is the service like this?
@Injectable()
export class PointService {
getPoint(): {
}
}
How can I share data, eg: localPoint, among pages? Like this?
@Injectable()
export class PointService {
localPoint: any;
}
How can I ensure each service share ONE instance?
If you can tell me some website or open source project about this, I’ll happy to learn by myself.
Thanks
Making sure you have no providers
on any components, only in the app module. Oh, and define a proper type instead of abusing any
.
I would suggest: