T
T
tisha0772015-01-28 14:21:09
JavaScript
tisha077, 2015-01-28 14:21:09

How to configure route in CanJS so that links are without #?

How to configure route in CanJS so that links are without #!?
Now: example.com/#!/firstPage
Needed: example.com/firstPage
AngularJS uses $locationProvider.html5Mode(true);
EmberJS uses App.Router.reopen({ location: 'auto' });
Can't find similar functionality for CanJS...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Melnikov, 2015-01-28
@tisha077

It seems to me that there is no such
piece of code from routes.js

...
bindings: {
  hashchange: {
    paramsMatcher: paramsMatcher,
    querySeparator: "&",
    // don't greedily match slashes in routing rules
    matchSlashes: false,
    bind: function () {
      can.bind.call(window, 'hashchange', setState);
    },
    unbind: function () {
      can.unbind.call(window, 'hashchange', setState);
    },
    // Gets the part of the url we are determinging the route from.
    // For hashbased routing, it's everything after the #, for
    // pushState it's configurable
    matchingPartOfURL: function () {
      return location.href.split(/#!?/)[1] || "";
    },
    // gets called with the serialized can.route data after a route has changed
    // returns what the url has been updated to (for matching purposes)
    setURL: function (path) {
      location.hash = "#!" + path;
      return path;
    },
    root: "#!"
  }
},
...

there is no hint of a condition, such as whether to use an exclamation mark or not,
PS you can add it yourself)

W
whitecolor, 2015-02-02
@whitecolor

As it is not, just include the pushstate plugin canjs.com/docs/can.route.pushstate.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question