How to use the @angular/router.DefaultUrlSerializer function in @angular/router

To help you get started, we’ve selected a few @angular/router examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NativeScript / nativescript-angular / nativescript-angular / router / ns-location-strategy.ts View on Github external
pushStateInternal(state: any, title: string, url: string, queryParams: string): void {
        const urlSerializer = new DefaultUrlSerializer();
        const stateUrlTree: UrlTree = urlSerializer.parse(url);
        const rootOutlets = stateUrlTree.root.children;

        this.currentUrlTree = stateUrlTree;

        // Handle case where the user declares a component at path "/".
        // The url serializer doesn't parse this url as having a primary outlet.
        if (!Object.keys(rootOutlets).length) {
            const outletStates = this.statesByOutlet["primary"] = this.statesByOutlet["primary"] || [];
            const isNewPage = outletStates.length === 0;
            outletStates.push({
                state: state,
                title: title,
                queryParams: queryParams,
                segmentGroup: stateUrlTree.root,
                isRootSegmentGroup: true,
github NativeScript / nativescript-angular / nativescript-angular / router / ns-location-strategy.ts View on Github external
private callPopState(state: LocationState, pop: boolean = true) {
        const urlSerializer = new DefaultUrlSerializer();
        const rootOutlet = this.currentUrlTree.root.children[this.currentOutlet];

        if (state && rootOutlet) {
            this.currentUrlTree.root.children[this.currentOutlet] = state.segmentGroup;
        } else {
            // when closing modal view there are scenarios (e.g. root viewContainerRef) when we need
            // to clean up the named page router outlet to make sure we will open the modal properly again if needed.
            delete this.statesByOutlet[this.currentOutlet];
            delete this.currentUrlTree.root.children[this.currentOutlet];
            this.currentOutlet = Object.keys(this.statesByOutlet)[0];
        }

        const url = urlSerializer.serialize(this.currentUrlTree);
        const change = { url: url, pop: pop };
        for (let fn of this.popStateCallbacks) {
            fn(change);
github NativeScript / nativescript-angular / nativescript-angular / router / ns-location-strategy.ts View on Github external
const state = this.peekState(this.currentOutlet);
        if (!state) {
            return "/";
        }

        let tree = this.currentUrlTree;

        // Handle case where the user declares a component at path "/".
        // The url serializer doesn't parse this url as having a primary outlet.
        if (state.isRootSegmentGroup) {
            tree.root = state.segmentGroup;
        } else {
            tree.root.children[this.currentOutlet] = state.segmentGroup;
        }

        const urlSerializer = new DefaultUrlSerializer();
        const url = urlSerializer.serialize(tree);
        if (isLogEnabled()) {
            routerLog("NSLocationStrategy.path(): " + url);
        }
        return url;
    }
github Azure / Azure-AppServices-Diagnostics-Portal / AngularApp / projects / app-service-diagnostics / src / app / shared / services / generic-solution.service.ts View on Github external
getApiVersion(route: string): string | null {
    let urlTree = new DefaultUrlSerializer().parse(route);

    return 'api-version' in urlTree.queryParams ? urlTree.queryParams['api-version'] : null;
  }
github Uintra / Uintra / src / Uintra20 / Content / src / app / shared / utils / CustomUrlSerializer.ts View on Github external
parse(url: any): UrlTree {
    let dus = new DefaultUrlSerializer();
    return dus.parse(url);
  }
github thelgevold / angular-samples / aot / app.module.ngfactory.js View on Github external
this._NgProbeToken_2 = [import3.ɵb()];
        this._ɵg_3 = new import3.ɵg(this);
        this._APP_INITIALIZER_4 = [
            import0.ɵo,
            import4.ɵc(this.parent.get(import4.NgProbeToken, null), this._NgProbeToken_2),
            import3.ɵh(this._ɵg_3)
        ];
        this._ApplicationInitStatus_5 = new import0.ApplicationInitStatus(this._APP_INITIALIZER_4);
        this._ɵf_6 = new import0.ɵf(this.parent.get(import0.NgZone), this.parent.get(import0.ɵConsole), this, this._ErrorHandler_1, this.componentFactoryResolver, this._ApplicationInitStatus_5);
        this._ApplicationRef_7 = this._ɵf_6;
        this._ApplicationModule_8 = new import0.ApplicationModule(this._ApplicationRef_7);
        this._BrowserModule_9 = new import4.BrowserModule(this.parent.get(import4.BrowserModule, null));
        this._ɵba_10 = new import5.ɵba();
        this._ReactiveFormsModule_11 = new import5.ReactiveFormsModule();
        this._ɵa_12 = import3.ɵd(this.parent.get(import3.Router, null));
        this._UrlSerializer_13 = new import3.DefaultUrlSerializer();
        this._RouterOutletMap_14 = new import3.RouterOutletMap();
        this._LocationStrategy_15 = new import2.HashLocationStrategy(this.parent.get(import2.PlatformLocation), this.parent.get(import2.APP_BASE_HREF, null));
        this._Location_16 = new import2.Location(this._LocationStrategy_15);
        this._Compiler_17 = new import0.Compiler();
        this._NgModuleFactoryLoader_18 = new import0.SystemJsNgModuleLoader(this._Compiler_17, this.parent.get(import0.SystemJsNgModuleLoaderConfig, null));
        this._ROUTES_19 = [[
                {
                    path: '',
                    redirectTo: '/about',
                    pathMatch: 'full'
                },
                {
                    path: 'about',
                    component: import37.About
                },
                {
github ng-alain / delon / packages / auth / src / social / social.service.spec.ts View on Github external
parseUrl: jasmine.createSpy('parseUrl').and.callFake((value: any) => {
    return new DefaultUrlSerializer().parse(value);
  }),
};