How to retrieve View outside the controller - Openui5

前端 未结 3 876
甜味超标
甜味超标 2021-01-06 05:11

If I use this.getView() inside the controller of a view I can retrieve it without problems. How can I retrieve the view if I am outside the controller (e. g. in

3条回答
  •  没有蜡笔的小新
    2021-01-06 05:24

    You can instantiate another view using:

    var view = sap.ui.jsview("");
    

    If you´re using different view types you can choose the necessary function from here.

    To avoid multiple instantiation you could do something like this:

    var view = sap.ui.getCore().byId("id");
    
    if (view === undefined) {
        view = sap.ui.jsview("id", "");
    }
    

    See this for more details regarding view definition/instantiation and IDs.

提交回复
热议问题