In my IronRouter.js file I have a route to the home defined like this:
Router.route('/', {
name: 'home',
waitOn: function() {
return [
Meteor.subscribe('infosContainers'),
Meteor.subscribe('infosMachines'),
Meteor.subscribe('alertes'),
];
},
fastRender: true,
});
Then I want to convert it into this kind of definition but the waitOn
isn't working and creates an error :
Router.route('/', function(){
this.layout('layout');
this.render('home');
this.next();
waitOn: function() {
return [
Meteor.subscribe('infosContainers'),
Meteor.subscribe('infosMachines'),
Meteor.subscribe('alertes'),
];
};
fastRender: true;
});
So how can I convert it into the 2nd definition ?
You put waitOn property inside of function declaration, which is just wrong javascript syntax, convert it to this way:
Router.route('/', {
fastRender: true,
subscriptions: function() {
return [
Meteor.subscribe('infosContainers'),
Meteor.subscribe('infosMachines'),
Meteor.subscribe('alertes'),
];
},
action: function() {
if (this.ready()) {
this.layout('layout');
this.render('home');
}
}
});
Iron router guide: http://iron-meteor.github.io/iron-router/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.