1. 程式人生 > >ng-alian 復用標簽相關設置

ng-alian 復用標簽相關設置

mod tor com iss .com set 目標 git mode

排除復用

import { ReuseTabMatchMode, ReuseTabService } from ‘@delon/abc‘;

export class StartupService {
    constructor(
        private reuseTabService: ReuseTabService,
        private inj: Injector) {
    }

    load(): Promise<any> {
        // only works with promises
        const pLoadData = new Promise(async (resolve, reject) => {
            // reuse-tab  是否重用頁面,把這個頁面排除了,所以只要跳轉到別的頁面 目標tab就會消失
            this.reuseTabService.mode = ReuseTabMatchMode.URL;
            const excludes = new Array<RegExp>();
            excludes.push(new RegExp(‘/target-route‘));
            this.reuseTabService.excludes = excludes;
            resolve({});
        });
        return pLoadData;
    }
}

參考資料

https://github.com/cipchk/ng-alain/issues/101

跳轉關閉tab

this.router.navigateByUrl(`/target-route`,{
    skipLocationChange:true
});

skipLocationChange:Navigates without pushing a new state into history.
ng-alain的tab根據路由的history生成=>tab沒有關閉=生成了history=>要關閉tab,需要不保留history
關鍵詞:angular 4 route navigate without pushing a new state into history.

參考資料

https://angular.io/api/router/NavigationExtras

ng-alian 復用標簽相關設置