Skip to Content

Init function not called in Component.js

Dear All,

In my plunk below: https://plnkr.co/edit/ksmw5NBh12gImVek2P3C routing not working because Component is not instantiate could you please help me to understand why and how to correct it ?

Add comment
10|10000 characters needed characters exceeded

  • Former Member

    Hi Jonathan,

    Just my guess. Can you try changing "viewPath" under routing section in manifest.json to

    "viewPath": "agoratoolsui5.app",

    rather than

    "viewPath": "app"
  • Get RSS Feed

3 Answers

  • Best Answer
    Feb 02, 2017 at 01:29 AM

    Hello Jonathan,

    You have placed the init code in metadata, which is not correct. Your component.js code should be like below:

    sap.ui.define(['sap/ui/core/UIComponent', "sap/ui/model/json/JSONModel"],
      function(UIComponent, JSONModel) {
        "use strict";
    
        var Component = UIComponent.extend("agoratoolsui5.Component", {
    
          metadata: {
            manifest: "json"
          },
          init: function() {
            // call the init function of the parent
            UIComponent.prototype.init.apply(this, arguments);
            this.getRouter().initialize();
            console.log('init router');
          }
    
        });
    
      });
    

    Thank you!

    Best Regards,

    Sai.

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 01, 2017 at 09:10 PM

    Hi Murali,

    Thanks for your help, but not working...

    Any other idea?

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 02, 2017 at 07:46 AM

    Hi Sai,

    Thanks a lot works now :)

    Add comment
    10|10000 characters needed characters exceeded