iron router - How to extend a main controller within a meteor package -


what right way extend main controller within meteor package?

this case, main controller inside app.js file, located in

both/controllers/app.js 

the content is

appcontroller = routecontroller.extend({   layouttemplate: 'applayout' }); 

inside my-package folder, i've created router.js file

packages/my-package/lib/router.js 

below content of file, here came question: why if move dashboardcontroller declaration outside meteor.startup() function, doesn't work?

dashboardcontroller = appcontroller.extend({}); // here doesn't work  meteor.startup(function () {      router.route('/dashboard', {         controller: dashboardcontroller,         name: 'dashboard' }); 

the output is

referenceerror: appcontroller not defined 

why if move dashboardcontroller declaration outside meteor.startup() function, doesn't work?

that's because of load order of meteor build process : every package js files loaded according dependencies between them , after actual application code executed (which makes sense).

the solution move dashboardcontroller inside meteor.startup block it's executed after application code had chance define appcontroller.

you move appcontroller inside application-core or application-controllers local package of yours , depend on package.


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -