When I use Router.current().route.path within my TutorsBySkillController Route it keeps returning me a null response. I suspect this is because I am using parameters in the URL.
This is the route with the problem:
Router.route('/expertise/:skillname/:tutorLimit?', {
name: 'tutorsBySkill',
controller: 'TutorsBySkillController'
})
This the controller, data() is where nextPath is determined.
TutorListController = RouteController.extend({
template: 'home',
increment: 6,
tutorLimit () {
return parseInt(this.params.tutorLimit) || this.increment
},
findOptions () {
return {sort: this.sort, limit: this.tutorLimit()}
},
skillname() {
return this.params.skillname || 'Javascript'
},
findSelector () {
return this.selector()
},
subscriptions () {
this.tutorsSub = Meteor.subscribe('tutors', this.findSelector(), this.findOptions())
},
tutors () {
return Tutors.find(this.findSelector(), this.findOptions())
},
data () {
const currentSkill = this.params.skillname
const hasMore = this.tutors().count() === this.tutorLimit()
return {
tutors: this.tutors(),
ready: this.tutorsSub.ready,
nextPath: hasMore ? this.nextPath() : null
}
}
})
TutorsBySkillController = TutorListController.extend({
sort: {name: 1, _id: 1},
selector () {
return { 'expertise.skillname': this.skillname() }
},
nextPath () {
return Router.routes.tutorsBySkill.path({tutorLimit: this.tutorLimit() + this.increment})
}
})
To be clear, the routes load perfectly, with the right data, sorted and selected right. The only thing that fails is the Router path function, it keeps returning null.
I am using nextPath to create a load more button.
TLDR The parameters are not getting to the Router.current.route.path!
Help()? Thanks!