refactor(app): permit to use PathLocationStrategy

close #258
This commit is contained in:
tibing 2016-10-19 17:21:25 +03:00
parent 0beef0b8a9
commit ec0e5aa673
5 changed files with 20 additions and 21 deletions

View file

@ -76,8 +76,12 @@ export class BaMenuService {
}
// we have to collect all paths to correctly build the url then
item.route.paths = parent && parent.route && parent.route.paths ? parent.route.paths.slice(0) : [];
item.route.paths.push(item.route.path);
if (Array.isArray(item.route.path)) {
item.route.paths = item.route.path;
} else {
item.route.paths = parent && parent.route && parent.route.paths ? parent.route.paths.slice(0) : ['/'];
item.route.paths.push(item.route.path);
}
if (object.children && object.children.length > 0) {
item.children = this._convertArrayToItems(object.children, item);
@ -95,10 +99,6 @@ export class BaMenuService {
protected _prepareItem(object:any):any {
if (!object.skip) {
let itemUrl = this._router.serializeUrl(this._router.createUrlTree(object.route.paths));
object.url = object.url ? object.url : '#' + itemUrl;
object.target = object.target || '';
object.pathMatch = object.pathMatch || 'full';
return this._selectItem(object);
@ -108,11 +108,7 @@ export class BaMenuService {
}
protected _selectItem(object:any):any {
if (object.children || object.pathMatch === 'full') {
object.selected = object.url === ('#' + this._router.url);
} else {
object.selected = ('#' + this._router.url).indexOf(object.url) === 0;
}
object.selected = this._router.isActive(this._router.createUrlTree(object.route.paths), object.pathMatch !== 'full');
return object;
}
}