hi, I am having a requirement like below.
Lets say, there are tow pages in my app. 1 - Search Page 2. Display search results Page.
When user enters some search criteria in Search page and click on “Search Button”. Then I should display data in Search results page. (Page 2). How my design should be?
You would want to use a factory to have access to the data between controllers. Take a look at our tabs or sidemenu starter apps, which have a factory set up for data.
I’ve reviewed a number of docs and trying to figure out the best way of doing this.
The comments in the tab starter project factories mention “// Might use a resource here that returns a JSON array”
But I can’t find any good instructions for how to implement a resource that:
- allows for sharing of state ie. data between two controllers that utilize the factory
- doesn’t make a new server call when switching views
- implements the getters/setters practice
- Handles the HTTP request within the factory and doesn’t offload to the view-controller (this seems to avoid the goal of sharing the data between two controllers/views).
In other words, exactly what the demo does but implementing a resource.
The ionic learn on backend services doesnt do #1 or #4
These tutorials on resources also don’t really complete the picture:
Thanks in advance!
To share data between controllers I am using services. These services are singleton and so we have no issues of maintaining state.
like this ionic tutorial ?
I’ve been using this (and versions of this) and it’s been fantastic