0

When using the can.Control.route documented here, I can not manage to set default parameters values as it is possible when using the classical declarative way as follow :

can.route("content/:type", {type: "videos" });

Is there a way to set the default value of a router parameter when using the route Control ?

Thanks for assistance.

ramblinjan
  • 6,578
  • 3
  • 30
  • 38
Thomas
  • 1,410
  • 10
  • 24

1 Answers1

0

You should be able to define the route in your control and then set the default value as described above:

can.Control.extend({
  'content/:type route': function() {
    //
  }
});

can.route("content/:type", { type: "videos" });
Daff
  • 43,734
  • 9
  • 106
  • 120
  • Hello. Thanks for feedback. It was not really what I was searching for. If I do that way, it makes me write the same piece of code twice. I think I'll switch back to the declarative way. – Thomas Nov 20 '13 at 14:50
  • Yes it does but there isn't really a way to do anything more but declare the route as a string in the Control route plugin. Although content/ should call the same route with an empty type, so you could just use `data.type || 'video'` in the handler. – Daff Nov 20 '13 at 15:18