我的 sapui5 应用程序中有一个 View ,在按下按钮时我想将一些数据传递到 Controller 、按下事件时调用的函数。 下面是代码片段:
<HBox justifyContent="SpaceAround" alignItems="Center" >
<Input type="Tel" pattern="[0-9]*" inputmode="numeric"
value="{path:'cart>Quantity/value',
type: 'sap.ui.model.type.Integer'}"
class="qtyInput" editable="{cart>Quantity/isEditable}"/>
<core:Icon src="sap-icon://delete" press="deleteItem" visible="{cart>isDeletable}"/>
</HBox>
在这里,我需要将“{cart>lineNumber}”和“{cart>itemKey}”传递给 Controller 中的函数“deleteItem”。 请提出建议。
最佳答案
您可以尝试使用 sapui5 CustomData 在事件上传递自定义数据。 为此,您需要在 View 中添加以下命名空间:
xmlns:app="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"
并在 Icon 元素内添加 app:propertyName=“value”。
请看下面的示例,我根据所需的更改更新了您的代码:
<core:Icon src="sap-icon://delete" press="deleteItem" visible="{cart>isDeletable}" app:lineNumber="{cart>lineNumber}" app:itemKey="{cart>itemKey}"/>
谢谢。
关于sapui5 - SAPUI5中如何将数据从 View 传递到 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37018172/