I would use a service (injected as provider) to handle data. While you can pass data with the push method thanks to the navigation controller you can’t pass it with the pop method.
P.S.: If you inject the service as provider in the parent component (like the app component) it will be automatically accessible to all its child components and it will be the same instance of the service.
When you put an access modifier on a constructor parameter, as you did with private data: MySharedObject, TypeScript automatically creates a private member called data and initializes it for you. You don’t need to (and shouldn’t) declare or assign to mySharedObj explicitly.
It’s a part of the language I dislike. It’s akin to having implicit getters and setters in other languages. I like to see the member variables explicitly written in all classes.
[quote=“ryanlogsdon, post:8, topic:59515”]I like to see the member variables explicitly written in all classes.
[/quote]
That’s cool, but if you’re going to do it that way, leave the private off the constructor parameter and give the property a proper type instead of any.