Skip to Content
1

share data between controllers

Oct 30, 2017 at 08:48 AM

56

avatar image

hello

i need to share data between controllers in the same app.

routing/navigation with parameters is not an option - there is no direct navigation between the controllers/views.

options being considered include having a 'global' model OR using an EventBus.

any thoughts/comments greatly appreciated.

any other options?

cheers

pas.

pas
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Christian Schuff Oct 30, 2017 at 03:23 PM
0

Hi Pas,

first of all: Don't store the data in a global object! Never do that! :)

Having a model on your Component does not all make it 'global'. It is still very well contained inside your application and does not disturb or pollute the launchpad or any other application.

// 'sending' controller
this.getOwnerComponent().setModel(oModel, "data");

// 'reveiving' controller
this.getModel("data")

That is probably the solution to go for.

BR

Chris

Share
10 |10000 characters needed characters left characters exceeded
Jun Wu Oct 30, 2017 at 11:17 AM
0

you can put the model in component, which will be global, all the view can see it...

Show 3 Share
10 |10000 characters needed characters left characters exceeded

A model in the Component is explicitly NOT global. It is owned by the Component and propagated to it‘s children. A global model is what you set on the core with sap.ui.getCore().setModel()

0
Christian Schuff

i mean

Component.setmodel
0
Christian Schuff

my global mean "local" global......

0