cancel
Showing results for 
Search instead for 
Did you mean: 

share data between controllers

former_member277448
Participant

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.

Accepted Solutions (1)

Accepted Solutions (1)

former_member201620
Participant
0 Kudos

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

Answers (1)

Answers (1)

junwu
Active Contributor
0 Kudos

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

former_member201620
Participant
0 Kudos

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()

junwu
Active Contributor
0 Kudos

i mean

Component.setmodel
junwu
Active Contributor
0 Kudos

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