Skip to Content
0
Former Member
May 19, 2016 at 07:59 PM

getRouter

195 Views

Hi,

has anyone an idea how I get the router from a .js File with no Controller?

I have a component.js where I initialize the Router with the manifest.json:

sap.ui.define([
   "sap/ui/core/UIComponent"
], function (UIComponent) {
   "use strict";
   return UIComponent.extend("app.Component", {
      metadata : {
            manifest: "json"
      },
      init : function () {
         UIComponent.prototype.init.apply(this, arguments);
         this.getRouter().register("router");
         this.getRouter().initialize();
      }
   });
});
  "routing": {
    "config": {
  "routerClass": "sap.m.routing.Router",
  "viewType": "XML",
  "viewPath": "app.view",
  "controlId": "app",
  "controlAggregation": "pages",
  "targetControl": "navContainer",

  "transition": "slide",
  "clearTarget": "false",
    },

And I have a app.controller where load and execute the test.js:

jQuery.sap.require("app/controller/tracking");
sap.ui.define([
  "app/controller/BaseController"

], function (BaseController) {
  "use strict";
  return BaseController.extend("app.controller.App", {
  onInit: function() {
  }
  });

Now I want to get the router in my test.js. It doesn't work with sap.ui.core.routing.Router.getRouter(routerId);

Thank you 😊