Domanda

I have some routes in my App.controller which i like to extend on init (I get the routes from server). What is the method or function to append the routes?

I am looking for something like this

this.application.addRoute({
  route: 'new-page',
  action: 'showNewPage'
});

Lets say i have this setup below to clarify my questions:

Ext.define('APP.controller.AppController',{
    extend: 'Ext.app.Controller',  
    alias: 'appcontroller',
    config : {
        routes : {
            'page'          : {
                action: 'showPage'          
            }
      },
      init: function() { 

       // How to add new route which will be added to config.routes of this controller?
       this.addRoute({
           route: 'new-page',
           action: 'showNewPage'
       });

      },
      showPage: function(){
      },
      showNewPage: function(){
      }
});
È stato utile?

Soluzione

Turns out there is a setRoutes() method :)

Ext.define('APP.controller.AppController',{
    extend: 'Ext.app.Controller',  
    alias: 'appcontroller',
    config : {
        routes : {
            'page'          : {
                action: 'showPage'          
            }
      },
      init: function() { 

       // Adding the routes
       this.setRoutes({
           'page'          : {
                action: 'showPage'          
            },
            'new-page'          : {
                action: 'showNewPage'          
            }
       });

      },
      showPage: function(){
      },
      showNewPage: function(){
      }
});
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top