I have a controller:
Menu.Controller.js:
sap.ui.define([
"sapit/ext/utils/BaseController",
"sap/ui/model/json/JSONModel",
"sap/ui/model/Sorter",
"sap/ui/model/Filter",
"sapit/nova/model/constants",
"sapit/ nova /model/formatter",
"sapit/ nova /util/Helper",
"sapit/ nova /util/Validator",
"sapit/ nova /util/ItemService"
], function(BaseController, JSONModel, Sorter, Filter, constants, formatter, Helper, Validator, ItemService) {
"use strict";
return BaseController.extend("sapit.nova.controller.Menu", {
formatter: formatter,
helper: new Helper(),
itemService: new ItemService(),
onInit: function() {
this.fragmentProcess = sap.ui.xmlfragment("sapit.nova.view.fragment.Process", this);
// attach events
this.getRouter().attachRouteMatched(jQuery.proxy(this.onRouteMatched, this));
},
onRouteMatched: function(oEvent) {
var oPage = this.byId("menuProcessor");
var sRouteName = oEvent.getParameter("name");
if (sRouteName === "Menu") {
// show fragment
this.helper.clearFragment(oPage);
this.helper.showFragment(oPage, this.fragmentProcess);
}
I have the corresponding xml view as Menu.view.xml:
mvc:View controllerName="sapit.nova.controller.Menu" xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc">
<Page id="menuProcessor" title="{i18n>menuPageTitle}" showNavButton="false">
</Page>
</mvc:View>
My router config is:
"routes": [{
"pattern": "/admin",
"name": "Main",
"target": ["menu"]
},
"targets": {
"menu": {
"viewName": "Menu",
"viewLevel": 1,
"controlAggregation": "masterPages"
}
The problem is when I run this application control is going to onInit () of the menu.controller but it's not going to onRouteMatched although it's getting the instance of router attached to this view.
Every time i run this application i am getting an Error after entering the onInit() and rest of code doesn't work and view doesn't come up.
Uncaught (in promise) Error: Cannot instantiate object: "new" is missing!
at constructor (sap-ui-core.js:640)
at constructor (sap-ui-core.js:1601)
at constructor (sap-ui-core.js:1571)
at f (sap-ui-core.js:638)
at f (sap-ui-core.js:284)
at p (sap-ui-core.js:285)
at _ (sap-ui-core.js:286)
at Object.properties (sap-ui-core.js:286)
at l (sap-ui-core.js:298)
at B.getText (sap-ui-core.js:296)
Can you please suggest me in this regard.
Thanks !!
See Question&Answers more detail:os