Super duper flexible component based router for developing wicked awesome single page apps with KnockoutJS.
$ yarn add ko-component-router
...or...
$ npm install -S ko-component-router
import ko from 'knockout'
import 'ko-component-router'
ko.components.register('app', {
viewModel: class App {
constructor() {
this.routes = {
'/': 'home',
'/user/:id': 'user'
}
}
},
template: `
<ko-component-router params="routes: routes"></ko-component-router>
`
})
ko.component.register('home', {
template: `<a href="/users/1234">Show user</a>`
})
ko.components.register('user', {
viewModel: class User {
constructor(ctx) {
// ctx.params
//
// ...and more!
}
}
})
ko.applyBindings()