can-route
Version:
Observable front-end application routing for CanJS.
48 lines (35 loc) • 1.08 kB
Markdown
3.3
Initializes the two way relationship between the url and route.data.
`route.start()`
Sets up the two-way binding between the hash and the [can-route.data can-route.data] and sets the route.data to its initial values. If URL data and route.data set at the same time the URL data will take precedence.
```html
<mock-url></mock-url>
<script type="module">
import "//unpkg.com/mock-url@^5.0.0";
import {route} from "can";
route.register( "{page}", { page: "home" } );
route.start();
console.log( route.data.page ); // -> "home"
</script>
```
7
{can-route} The can-route object.
## Use
After setting all your routes, call `route.start()`.
```js
import {route} from "can";
route.register( "overview/{dateStart}-{dateEnd}" );
route.register( "{type}/{id}" );
route.start();
console.log( route.data ); // -> {
// dateEnd: undefined,
// dateStart: undefined,
// id: undefined,
// type: undefined
// }
```
can-route.start start
can-route.static