on 07-19-2016 4:17 PM
Hi,
i'm following an openSap tutorial and in the following code snippet i get the error: "AddFlexibilityRequest.controller.js:8 Uncaught (in promise) TypeError: this.getRouter is not a function".
sap.ui.define(["sap/ui/core/mvc/Controller" ], function(Controller) {
"use strict";
return Controller.extend("e4u.usr.a627603.FlexiForecast.WebContent.controller.AddFlexibilityRequest", {
onInit: function() {
this.getRouter().getRoute("addFlexibilityRequest").attachPatternMatched(this._onRouteMatched, this);
},
_onRouteMatched : function() {
var oModel = this.getModel(this);
oModel.metaDataLoaded().then(this._onMetaDataLoaded.bind(this));
},
[...]
}) |
I know i can handle this by typing:
sap.ui.core.UIComponent.getRouterFor(this);
But why does this error occur?
Thanks,
Tobias
Probably the tutorial uses a base controller (as e.g. most of the WebIDE templates create) which implements a method "getRouter" containing the logic you described in the second paragraph of your post. The base controller inherits that method to specific controllers. As your controller is used on the sap.ui.core.mvc.Controller you do not have this method.
Regards,
Florian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.