javascript - Optional parameters in Meteor router -
i have path in meteor
path: '/my-url/:groupid?', i have added question mark indicate groupid not used. in data check whether group id set this.params.hasownproperty('groupid') have come across router thinks groupid set if isn't (don't know why) value undefined.
therefore, tried
console.log(this.params.hasownproperty('groupid')); console.log('groupid' in this.params); console.log(this.params.groupid); and evaluate to
> true > true > undefined so guess hasownproperty not best way check whether groupid set since doesn't check undefined values.
what better way check this? why hasownproperty evaluate true if url /my-url?
i think you've answered on question. have same problem , check is:
if (this.params.groupid) { } else { } this not yet confirmed, think long provide :groupid, you're have in params, regardless exists or not.
Comments
Post a Comment