hirouter
v0.1.2
Published
HTML5 history and router, simple, powerful and no framework.
Downloads
10
Readme
HiRouter
HTML5 history and router, simple, powerful and no framework.
It is a implementation of route-trie
Demo
var HiRouter = require('hirouter');
var router = new HiRouter();
// define router handler:
router
.when('/projects/:id', function(state) {
// body...
console.log(state)
// {
// fragment: '/projects/xxxxxxxId?debug=true',
// pathName: '/projects/xxxxxxxId',
// search: '?debug=true',
// params: {
// id: 'xxxxxxxId'
// }
// }
})
.when('/organizations/:id', function(state) {
// body...
console.log(state)
})
.otherwise(function(state) {
// body...
})
// start listen
router.start();
// navigate to a url
router.navigate('/organizations/xxxId')
// navigate to a url and don't trigger route handler
router.navigate('/organizations/xxxId', {trigger: false})