Input 如何将textField中的用户输入值与property“绑定”;“文本”;链接的名称(sapui5)

Input 如何将textField中的用户输入值与property“绑定”;“文本”;链接的名称(sapui5),input,hyperlink,textfield,sapui5,Input,Hyperlink,Textfield,Sapui5,我有一个文本字段: var favInput = new sap.ui.commons.TextField("tfFavorites",{ value : 'Give a name to the favorite....', imeMode: sap.ui.core.ImeMode.Active, editable: true }); 我有一个按钮: var saveFavorButton = new sap.ui.commons.Button({ text : "Crea

我有一个文本字段:

  var favInput = new sap.ui.commons.TextField("tfFavorites",{
  value : 'Give a name to the favorite....',
  imeMode: sap.ui.core.ImeMode.Active,
 editable: true  });
我有一个按钮:

 var saveFavorButton = new sap.ui.commons.Button({  text : "Create new favorite" });
按下按钮后,我想构建一个“createNewFavorite”函数,该函数将创建一个带有用户文本输入名称的链接。例如:

var myFavorites1 = new sap.ui.commons.Link("myfav1",{
      text: "my favorite 1",
              });

如何创建“createNewFavorite”函数?非常感谢

您可以使用以下内容:

saveFavorButton.attachPress(function() {
    var myFavorites1 = new sap.ui.commons.Link("myfav1",{
        text: favInput.getValue()
    });
    //now you just need to add the new control to your view
});

但更好的方法是创建一个(JSON)模型,然后将其绑定到文本字段,然后可以对其进行扩展和/或收缩,以满足存储更多收藏夹的需要

saveFavorButton.attachPress(function() {
    var myFavorites1 = new sap.ui.commons.Link("myfav1",{
        text: favInput.getValue()
    });
    //now you just need to add the new control to your view
});

但更好的方法是创建一个(JSON)模型,然后将其绑定到文本字段,然后可以对其进行扩展和/或收缩,以满足存储更多收藏夹的需要

saveFavorButton.attachPress(function() {
    var myFavorites1 = new sap.ui.commons.Link("myfav1",{
        text: favInput.getValue()
    });
    //now you just need to add the new control to your view
});

但更好的方法是创建一个(JSON)模型,然后将其绑定到文本字段,然后可以对其进行扩展和/或收缩,以满足存储更多收藏夹的需要

saveFavorButton.attachPress(function() {
    var myFavorites1 = new sap.ui.commons.Link("myfav1",{
        text: favInput.getValue()
    });
    //now you just need to add the new control to your view
});

但更好的方法是创建一个(JSON)模型,然后将其绑定到文本字段,然后可以对其进行增长和/或收缩,以适应更多收藏夹的存储。

在按钮的属性中,您可以添加一个属性按钮,您可以在其中定义函数createNewFavorite,如下所示:

var saveFavorButton=new sap.ui.commons.Button( {
文本:“创建新收藏夹”, 按:函数() { var myFavorites1=新的sap.ui.commons.Link(“myfav1”, { 文本:favInput.getValue() }); } });


或者您可以编写“press:createNewFavorite”,并在控制器中定义此函数createNewFavorite。

在按钮的属性中,您可以添加属性press,在其中您可以定义函数createNewFavorite,如下所示:

var saveFavorButton=new sap.ui.commons.Button( {
文本:“创建新收藏夹”, 按:函数() { var myFavorites1=新的sap.ui.commons.Link(“myfav1”, { 文本:favInput.getValue() }); } });


或者您可以编写“press:createNewFavorite”,并在控制器中定义此函数createNewFavorite。

在按钮的属性中,您可以添加属性press,在其中您可以定义函数createNewFavorite,如下所示:

var saveFavorButton=new sap.ui.commons.Button( {
文本:“创建新收藏夹”, 按:函数() { var myFavorites1=新的sap.ui.commons.Link(“myfav1”, { 文本:favInput.getValue() }); } });


或者您可以编写“press:createNewFavorite”,并在控制器中定义此函数createNewFavorite。

在按钮的属性中,您可以添加属性press,在其中您可以定义函数createNewFavorite,如下所示:

var saveFavorButton=new sap.ui.commons.Button( {
文本:“创建新收藏夹”, 按:函数() { var myFavorites1=新的sap.ui.commons.Link(“myfav1”, { 文本:favInput.getValue() }); } });

或者您可以编写“press:createNewFavorite”,并在控制器中定义此函数createNewFavorite