on 02-04-2017 1:48 AM
hello,
i have a controller/view that displays a form for the user to make selections.
the selections are stored in a json model.
i need to pass the selections model to another view/controller where other stuff is done.
i could create a global json model and access it from both views or pass the model from one view to the other.
any suggestions as to which way is better?
cheers
pas
Depending on your business case, there are several approaches when it comes to setting models. Generally, You'd set your model on your ...
In your case, if you have only two views that need the selection data, you could set the model to the first view and then pass it on to the second view on navigation. Something like this:
<App navigate=".onNavigate" />
onNavigate: function(event) { // minimal example
const targetView = event.getParameter("to");
if (targetView.byId("/*idOfThatPageIWant*/")) {
const sourceView = event.getParameter("from");
const modelName = "/*thatModelName*/";
targetView.setModel(sourceView.getModel(modelName), modelName);
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
global model
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jun Wu,
Any reason why global model is preferred over the other? I am just trying to understand the rationale behind your thoughts.
Lets say if we have bunch of pages in our app, with global model approach, we tend to provide access to unwanted views (which in a way is polluting the global space)
Your thoughts could clarify better.
Thanks,
Murali L
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.