数据绑定文本未显示在我的 UI5 应用程序中
Data-binded Text is not shown in my UI5-Application
我想将我的 JSON-模型中的文本绑定到按钮的文本。
我的控制器初始化我的模型:
onInit: function () {
var oModel = new JSONModel({
"test": "Hello"
});
this.getView().setModel(oModel, "jsonFile");
}
我的视图如下所示:
<mvc:View xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc" controllerName="sap.ui.demo.nav.controller.Home">
<Page id="_IDEGen_page0" title="{i18n>homePageTitle}" class="sapUiResponsiveContentPadding">
<content>
<Button id="_IDEGen_button0" text="Start new Game" press="onPressStartGame"/>
<Button text="{jsonFile>test}"/>
</content>
</Page>
</mvc:View>
但是当我 运行 我的应用程序时,ui5-inspector 显示绑定处于活动状态,但未显示文本。
我不知道在这种情况下可能是什么问题。谁能帮我?可能是什么问题,文本未显示?
您忘记了绑定中的斜线
<Button text="{jsonFile>/test}"/>
我想将我的 JSON-模型中的文本绑定到按钮的文本。
我的控制器初始化我的模型:
onInit: function () {
var oModel = new JSONModel({
"test": "Hello"
});
this.getView().setModel(oModel, "jsonFile");
}
我的视图如下所示:
<mvc:View xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc" controllerName="sap.ui.demo.nav.controller.Home">
<Page id="_IDEGen_page0" title="{i18n>homePageTitle}" class="sapUiResponsiveContentPadding">
<content>
<Button id="_IDEGen_button0" text="Start new Game" press="onPressStartGame"/>
<Button text="{jsonFile>test}"/>
</content>
</Page>
</mvc:View>
但是当我 运行 我的应用程序时,ui5-inspector 显示绑定处于活动状态,但未显示文本。
我不知道在这种情况下可能是什么问题。谁能帮我?可能是什么问题,文本未显示?
您忘记了绑定中的斜线
<Button text="{jsonFile>/test}"/>