I have issues understanding the change of the this reference in my code. So there are three things I don't get:
- When I try to get my model in the - onInit, I get:- "Cannot read property 'getProperty' of undefined". - But I can access the model of my view within the XML view since I defined the model in my manifest.json and use the manifest in my app Component. Why can't I access the model in the controller via - this.getView().getModel?
- In my - onDetailRouteHitmethod, I can get the model perfectly fine with- this.getView().getModel.
- When I call the - _Testmethod, I get this error again:- "Cannot read property 'getProperty' of undefined" 
So why can't I access the model in the onInit but in the onDetailRouteHit? And why can I access it in the onDetailRouteHit but not in the function I call after that? I'm used to Java where the this references the current object what I assume to be the controller I'm currently in in my example.
Are there "rules" of the this scope in JS / UI5?
sap.ui.define([
  "sap/ui/core/mvc/Controller"
], function(Controller) {
  "use strict";
  return Controller.extend("test.controller.Detail", {
    onInit: function() {
      var array1 = this.getView().getModel("myData").getProperty("/myDataSet");
      this.oRouter = this.getOwnerComponent().getRouter();
      this.oRouter.getRoute("detail").attachPatternMatched(this._onDetailRouteHit.bind(this));
    },
    _onDetailRouteHit: function(oEvent) {
      var array2 = this.getView().getModel("myData").getProperty("/myDataSet");
      this._Test();
    },
    _Test: function() {
      var array3 = this.getView().getModel("myData").getProperty("/myDataSet");
    }
  });
});
 
     
     
    