cancel
Showing results for 
Search instead for 
Did you mean: 

How to access data binding UI5 in js?

former_member589109
Participant
0 Kudos

Hi,
I've got simple app which i want the user to input some data and a controll field, which is simple 4 characters.
By that i mean that there is label with

text = {Code}

and it displays fine.
I've also a input field and in controller i can access it with simple

var input = this.getView().byId("input").getValue()

But i can't find a way to compare user input to {Code}.
What is the appropriate way to do it?

Accepted Solutions (1)

Accepted Solutions (1)

ericci
Active Contributor

As far as I can see your {Code} is inside your default model (you haven't specified a model so I just assumed it).

If you want to get the value of {Code} you can do

this.getView().getModel().getProperty("/Code")

This is a very basic thing to do. I would suggest you to first read carefully the documentation and video tutorial about how SAPUI5 works.

former_member589109
Participant
0 Kudos

You are right, it's in the default model (forgot to mention it), but the problem is that the

this.getView().getModel().getProperty("/Code")

Returns undefined

ericci
Active Contributor
0 Kudos

Well. are you sure that you have defined the default model with some value?

A working example to reproduce the issue would help 😉

former_member589109
Participant
0 Kudos

You are probably right that i should revise the ui5 course once again.
For now i received the Code with

var sObjectCode = this.getView().getModel().getObject( this.getView().getElementBinding().getPath()).Code;

Answers (0)