Skip to Content

How to pass values from view.js to controller.js

In my view.js, I have two text fields -- inputName and inputComment. I have a Submit button. When the Submit button is pressed, I want to pass the Name and Comment values to the Controller.js. I have tried everything I can think of but nothing works.

var oButton = new sap.ui.commons.Button({

text: "Submit",

press: function() {

oController.onSubmit.apply(oController, {

inputName: oName.Input.getValue(),

inputComment: oCommentInput.getValue()

});

)

How can I pass inputName and inputComment to the onSubmit function in the Controller?

Maybe someone can share their code on how they pass Input values to a function.

Thanks.

Sandy

Add comment
10|10000 characters needed characters exceeded

  • I got this to work but I think there should be a better way where I can use the parameters inputName and inputComment that are passed with oConroller.onSubmit.apply.

    onSubmit: function() {

    var name = sap.ui.getCore().getElementById("inputName").getValue();

    var comment = sap.ui.getCore().getElementById("inputComment").getValue();

  • Get RSS Feed

0 Answers