cancel
Showing results for 
Search instead for 
Did you mean: 

how to get reference to sap.m.App?

0 Kudos

Dear Guys,

I create a master view in which i put such code:


<mvc:View xmlns:mvc="sap.ui.core.mvc"

  xmlns:custom="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"

  xmlns="sap.m">

  <App id="myApp">

  </App>

</mvc:View>

I take this view as a base view from which I can nav to full screen views and split containers.

while how can i get the reference to "myApp" in other controller? I tried :


sap.ui.getCore().byId("myApp")

but not work.

Very appreciated if someone give me a hint.

Thanks,

Leon

Accepted Solutions (1)

Accepted Solutions (1)

gill367
Active Contributor
0 Kudos

Hi Leon,

If you want to get the reference in the child view inside the app container.

Try something like below.

this.getView().getParent().getParent();

Regards,

Sarbjeet Singh

Answers (1)

Answers (1)

maheshgonda
Product and Topic Expert
Product and Topic Expert
0 Kudos

hi ,

have one global variable in child view controller and assign the parent controller to this variable while instantiating .

ex:

in child view

sap.ui.core.Control.extend("a.sample.Control", {

     appController:null,
  init : function() {
  // instantiate a sub-control
  this._btn = new sap.m.Button();

//access appController here

  },

in parent view instantiating child view set the parent controller

this._detailsView = sap.ui.jsview("todolist.details"); 

this._detailsView.appController = this.getController()