Skip to Content
avatar image
Former Member

UIComponent's Model can not be accessed in View-Controller


I got the following problem:

I've done the SAPUI5 walkthrough tutorial in which in Component.js a model has been set via following code where this is sap.ui.core.UIComponent

var oInvoiceModel = new JSONModel(, oConfig.invoiceLocal));

this.setModel(oInvoiceModel, "invoice");

But in view controller I have no access. I have tested some ways like:




But everytime the result is undefined or empty.

I thought when something is set in Component.js it is aviable everywhere...

What I want to do in the end is setting a model in Component.js and loop over some data in this model in the controller of the view to build a dynamic UI.

Any ideas how I can accomplish this?

Thank you,


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Oct 18, 2015 at 05:07 PM

    Hi Dominik,

    Try like this in your controller and check?

    var oComponent = this.getOwnerComponent();          //Returns the Component


    Sai Vellanki.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 18, 2015 at 06:44 PM

    Hi Dominik,

    How about using setting and getting the model from the core something like this:




    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Kedar,

      yeah I know this method and it works.

      But in case this was not mentioned in the tutorial I wanted to do it like they told in the walkthrough.

      But it also works!

      Thank you and kind regards,