My app is made of packages. If I set up routes with iron router in one package, everything works as it should :
Router.route('/sessions', {
name: 'ride_sessions.list',
template: 'RideSessionList',
action: function () {
this.render();
},
data: function () {
templateData = {
rideSessions : RideSessions.find()
}
return templateData;
}
});
But if I try to use a route Controller like this :
RideSessionsListController = RouteController.extend({
template: 'RideSessionList',
action: function () {
this.render();
},
data: function () {
templateData = {
rideSessions: RideSessions.find()
}
return templateData;
}
});
Router.route('/sessions', {
name: 'ride_sessions.list',
controller: 'RideSessionsListController'
});
I get this error :
Error: RouteController 'RideSessionsListController' is not defined.
Is it a bug ? Or am I doing something wrong ? If I'm not in a smart-package it works fine.
You need to export all your global variables in package.js
file:
Package.onUse(function (api) {
...
api.export(['RideSessionsListController', ...]);
});