Is there a way to move async route function into component page e.g. beforeCreate

{
  path: '/sample/',
  async: function (routeTo, routeFrom, resolve, reject) {
    Request({url:'sample', params: {id : id} , 
      success: function (data){
        resolve({  componentUrl: './pages/sample.html'  },  { context: data});        
      }
    });
  }
}

instead of this i want to move codes inside script tag in component page
inside sample.html

beforeCreate: function(){
      var self = this;
.....
}
1 Like

Good idea.

But component script always execute after finding and matching route.

Maybe, if you will scan all component files (with Request), and get component script. Next, execute custom event (e.g. ā€œgetRouteā€). Next, fill router with results of call getRouteā€¦ After all init your app. :face_with_raised_eyebrow: