Sapui5 使用另一个控件的模型填充控件-智能手机问题

Sapui5 使用另一个控件的模型填充控件-智能手机问题,sapui5,Sapui5,我试图获得位于另一个视图上的控件模型,并将此模型应用于当前视图上的控件。 为此,我将以下代码放入控制器的onbeforeredering()函数中: var oModel = sap.ui.getCore().byId('<id of the control in another view>').getModel('<modelName here>'); sap.ui.getCore().byId('<id of the control in the current

我试图获得位于另一个视图上的控件模型,并将此模型应用于当前视图上的控件。 为此,我将以下代码放入控制器的onbeforeredering()函数中:

var oModel = sap.ui.getCore().byId('<id of the control in another view>').getModel('<modelName here>');
sap.ui.getCore().byId('<id of the control in the current view>').setModel(oModel, "<modelName here>");
sap.ui.getCore().setModel(data, "selection");
var-oModel=sap.ui.getCore().byId(“”).getModel(“”);
sap.ui.getCore().byId(“”).setModel(oModel(“”);
问题是这种结构在PC和平板电脑(android)上运行良好(控件sap.m.select中填充了项目),但在智能手机(android)上不起作用(sap.m.select控件为空)


如何解决这个问题?

正如@mjd在评论中所建议的,我使用了全局模型:

sap.ui.getCore().setModel(<shared model data>, "<modelName>");
然后在page2.view中(page1.view中使用相同的结构):


两种视图是否都在电话上呈现?模型仅在渲染视图时可用。是的,两个视图都渲染。我使用SplitApp控件,第一个视图在应用程序启动时呈现。第二个是导航到它时渲染的。嗨,为什么不使用一个可以由两个视图共享的全局模型呢?例如,您可以执行
sap.ui.getCore().setModel(,)sap.ui.getCore().getModel()引用模型在两个视图上。让我知道这是否适合你。当做
var oSelection = new sap.m.Select({
    id:     'selectionID',
    items: {
        path: "selection>/rootElementName", 
        template: new sap.ui.core.Item({
            text: "{selection>elementName}"
        })
    },
});