javascriptroutescanjscanjs-routing

How to set default params in can.Control.route


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.


Solution

  • 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" });