如何在某个视图中获取对另一个视图控件的引用? [英] How to get the reference to the another view control within some view?
问题描述
由ViewA.view.js"创建的ViewA绑定到一个JSONModel.在名为 ViewB 的视图中,我想获取 ViewA 绑定到的 JSONModel 中的数据.我怎样才能在ViewB.view.js"中获得对 ViewA 的引用?
ViewA created by "ViewA.view.js" is bound to a JSONModel. From within a view called ViewB, I would like to get the data in the JSONModel to which ViewA is bound. How can I possibly get the reference to ViewA within "ViewB.view.js"?
推荐答案
通常,紧密耦合视图以共享模型数据并不是最佳做法.更好的方法是使用在所有视图中都可用的全局模型.您可以通过调用 sap.ui.getCore().setModel(modelInstance, modelName) 来完成此操作.
In general it's not a best practice to tightly couple views to share model data. A better approach is to use a global model which is available in all your views. You do this by calling sap.ui.getCore().setModel(modelInstance, modelName).
这篇关于如何在某个视图中获取对另一个视图控件的引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!