Skip to content

Commit

Permalink
feat(md-breadcrumbs): allow for custom router
Browse files Browse the repository at this point in the history
  • Loading branch information
Thanood committed Dec 4, 2016
1 parent cb1f926 commit 192a678
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/breadcrumbs/breadcrumbs.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
import { customElement } from 'aurelia-templating';
import { inject } from 'aurelia-dependency-injection';
import {bindable, customElement} from 'aurelia-templating';
import {inject} from 'aurelia-dependency-injection';
import {Router} from 'aurelia-router';

// taken from: https://github.com/heruan/aurelia-breadcrumbs

@customElement('md-breadcrumbs')
@inject(Element, Router)
export class MdBreadcrumbs {
@bindable() router;

constructor(element, router) {
this.element = element;
this.aureliaRouter = router;
// this._childRouter = router;
// while (router.parent) {
// router = router.parent;
// }
// this.router = router;
}

bind() {
if (!this.router) {
this.router = this.aureliaRouter;
}
let router = this.router;
this._childRouter = router;
while (router.parent) {
router = router.parent;
}
this.router = router;
}

routerChanged() {
console.log('[breadcrumbs]', this.router);
}

navigate(navigationInstruction) {
this._childRouter.navigateToRoute(navigationInstruction.config.name);
// this.router.navigate(navigationInstruction.config.name);
Expand Down

0 comments on commit 192a678

Please sign in to comment.