从控制器访问核心模型不起作用 [英] Accessing Core Model from Controller Not Working

查看:58
本文介绍了从控制器访问核心模型不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Component.js 中添加了一个命名模型.我可以从任何视图访问具有其名称的模型,但我想从一个不适合我的控制器访问该模型.

I have added a named model in Component.js. I can access model with its name from any view but I want to access this model from one of the controllers which is not working for me.

sap.ui.core.getModel("modelName") 不起作用,sap.ui.getCore().getModel("modelName") 也不起作用工作.

sap.ui.core.getModel("modelName") is not working and sap.ui.getCore().getModel("modelName") is also not working.

如何从控制器引用其包含的组件和命名模型?

How to refer its containing Component and a named model from a controller?

推荐答案

如果模型是使用清单路径 sap.ui5->models 注册的,它似乎只能在控制器中使用

If the model was registered using the manifest path sap.ui5->models it seems to be available in the controllers only by

  this.getOwnerComponent().getModel(modelName);

我尤其在 i18n 模型上经历过这种情况.

I have experienced this especially for the i18n model.

这篇关于从控制器访问核心模型不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆