ramiel / router.js

Router.js is a simple and powerful javascript library to handle routing
116 stars 21 forks source link

Can't use an external controller object? #1

Closed ethanpil closed 10 years ago

ethanpil commented 10 years ago

I have app.js with:

app = { "homePage" : function(req, next) { alert('Hello'); } }

I have routes.js with:

var router = new Router() .addRoute('#/', app.homePage(req, next) ) .run('#/');

It seems like its not properly calling the functions?

image

ramiel commented 10 years ago

You need to pass just the reference to the function

var router = new Router()
   .addRoute('#/', app.homePage )
   .run('#/');
ramiel commented 10 years ago

I hope you fixed your code