當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Router.parseUrl方法代碼示例

本文整理匯總了TypeScript中@angular/router.Router.parseUrl方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Router.parseUrl方法的具體用法?TypeScript Router.parseUrl怎麽用?TypeScript Router.parseUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@angular/router.Router的用法示例。


在下文中一共展示了Router.parseUrl方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: switch

    .subscribe(action => {
      const { path, query: queryParams, extras = {} }: RouterMethodCall = action.payload;
      let commands: any[] = Array.isArray(path) ? path : [path];

      switch (action.type) {
        case routerActions.GO:
          router.navigate(commands, Object.assign({}, extras, { queryParams }));
          break;

        case routerActions.REPLACE:
          router.navigate(commands, Object.assign({}, extras, { queryParams, replaceUrl: true }));
          break;

        case routerActions.SEARCH:
          let urlTree: UrlTree = router.parseUrl(router.url);
          urlTree.queryParams = queryParams;
          router.navigateByUrl(urlTree, extras);
          break;

        case routerActions.SHOW:
          router.navigate(commands, Object.assign({}, extras, { queryParams, skipLocationChange: true }));
          break;

        case routerActions.BACK:
          location.back();
          break;

        case routerActions.FORWARD:
          location.forward();
          break;
      }
    });
開發者ID:ngrx,項目名稱:router-store,代碼行數:32,代碼來源:connect.ts

示例2:

    this.authService.login().subscribe(() => {
      this.setMessage();
      if (this.authService.isLoggedIn) {
        // Get the redirect URL from our auth service
        // If no redirect has been set, use the default
        let redirect = this.authService.redirectUrl ? this.router.parseUrl(this.authService.redirectUrl) : '/admin';

        // Redirect the user
        this.router.navigateByUrl(redirect);
      }
    });
開發者ID:Cammisuli,項目名稱:angular,代碼行數:11,代碼來源:login.component.1.ts

示例3:

 router.events.subscribe(s => {
   if (s instanceof NavigationEnd) {
     const tree = router.parseUrl(router.url);
     if (tree.fragment) {
       // you can use DomAdapter
       const element:any = document.querySelector("#" + tree.fragment);
       if (element) { 
         element.scrollIntoView(element); 
         document.body.scrollTop -= offset;
       }
     }
   }
 });
開發者ID:ladyleet,項目名稱:ng-cruise,代碼行數:13,代碼來源:app.component.ts

示例4: constructor

    constructor(private http: Http, private cookieService: CookieService, private shareService: ShareService, private router: Router, private location: Location) {

        var queryParams = this.router.parseUrl(router.url).queryParams;

        if (queryParams['share'] == 'true')
        {
            this.comparisonType = queryParams['analysis'] == 'monthly' ? 1 : 2;
        }
        else
        {
            this.comparisonType = 2;
        }

        this.favouriteCountiesCookieKey = 'favouriteCounties';

        this.LoadData();

        this.location.go('/performerii-lunii');
    }
開發者ID:OvidiuCaba,項目名稱:StatisticsRomania,代碼行數:19,代碼來源:performers.component.ts

示例5: constructor

    constructor(private http: Http, private shareService: ShareService, private router: Router, private location: Location) {

        this.GetCounties();

        var queryParams = this.router.parseUrl(this.router.url).queryParams;

        if (queryParams['share'] == 'true') {
            this.indicator = queryParams['chapter'].replace(new RegExp("\\+", "g"), ' ');
            this.comparisonType = queryParams['needToProcessAllYear'] == 'true' ? 2 : 1;
        }
        else {
            this.indicator = 'Forta de munca - salariu mediu net';
            this.comparisonType = 1;
        }

        this.needToProcessAllYear = this.comparisonType == 2;

        this.location.go('/statistici-judetene');
    }
開發者ID:OvidiuCaba,項目名稱:StatisticsRomania,代碼行數:19,代碼來源:county-details.component.ts

示例6: getUrlWithoutModal

	// ---
	// PRIVATE METHODS.
	// ---

	// I return the requested URL (as defined in the snapshot), less any of the "modal"
	// outlet segments.
	private getUrlWithoutModal( routerStateSnapshot: RouterStateSnapshot ) : UrlTree {

		var urlTree = this.router.parseUrl( routerStateSnapshot.url );
		var segment = urlTree.root;

		// Since the "modal" outlet is known to be directly off the primary view, we're
		// going to walk down the tree of primary outlets and delete any "modal" 
		// children. This should leave us with a UrlTree that contains everything that 
		// the original URL had, less the "modal" outlet.
		while ( segment && segment.children ) {

			delete( segment.children.modal );

			segment = segment.children[ PRIMARY_OUTLET ];

		}

		return( urlTree );

	}
開發者ID:bennadel,項目名稱:JavaScript-Demos,代碼行數:26,代碼來源:do-not-show-modal-on-refresh.guard.ts

示例7:

    this.authService.login().subscribe(() => {
      this.setMessage();
      if (this.authService.isLoggedIn) {
        // Get the redirect URL from our auth service
        // If no redirect has been set, use the default
        let redirect = this.authService.redirectUrl ? this.router.parseUrl(this.authService.redirectUrl) : '/admin';

        // #docregion preserve
        // Set our navigation extras object
        // that passes on our global query params and fragment
        let navigationExtras: NavigationExtras = {
          queryParamsHandling: 'preserve',
          preserveFragment: true
        };

        // Redirect the user
        this.router.navigateByUrl(redirect, navigationExtras);
        // #enddocregion preserve
      }
    });
開發者ID:Cammisuli,項目名稱:angular,代碼行數:20,代碼來源:login.component.ts

示例8: getUrlWithoutSecondary

	// ---
	// PRIVATE METHODS.
	// ---

	// I return the requested URL (as defined in the snapshot), less any the "secondary"
	// named-outlet segments.
	private getUrlWithoutSecondary( routerStateSnapshot: RouterStateSnapshot ) : UrlTree {

		var urlTree = this.router.parseUrl( routerStateSnapshot.url );
		var segment = urlTree.root;

		// Since the "secondary" outlet is known to be directly off the primary view 
		// (ie, not nested within another named-outlet), we're going to walk down the 
		// tree of primary outlets and delete any "secondary" children. This should 
		// leave us with a UrlTree that contains everything that the original URL had,
		// less the "secondary" named-outlet.
		while ( segment && segment.children ) {

			delete( segment.children.secondary );

			segment = segment.children[ PRIMARY_OUTLET ];

		}

		return( urlTree );

	}
開發者ID:bennadel,項目名稱:JavaScript-Demos,代碼行數:27,代碼來源:do-not-show-secondary-on-refresh.guard.ts

示例9: County

            .subscribe(result => {
                this.counties1 = result.json();
                this.county1 = 1;
                this.county1Text = this.counties1.find(x => x.id == 1)!.name;
                this.counties2 = new Array<ICounty>();
                var defaultCounty2 = new County();
                defaultCounty2.id = 0;
                defaultCounty2.name = '-----------------';
                this.counties2.push(defaultCounty2);
                this.counties1.forEach(x => this.counties2.push(x));
                this.county2 = 0;
                this.county2Text = this.counties2.find(x => x.id == 0)!.name;

                var queryParams = this.router.parseUrl(this.router.url).queryParams;
                if (queryParams['share'] == 'true') {
                    this.county1 = +queryParams['countyId1'];
                    this.county1Text = this.counties1.find(x => x.id == this.county1)!.name;
                    this.county2 = +queryParams['countyId2'];
                    this.county2Text = this.counties2.find(x => x.id == this.county2)!.name;
                }

                this.LoadData();
            });
開發者ID:OvidiuCaba,項目名稱:StatisticsRomania,代碼行數:23,代碼來源:county-details.component.ts

示例10: canActivate

 canActivate(): boolean | UrlTree {
   return this.currentUserService.isLoggedIn() || this.router.parseUrl('/login');
 }
開發者ID:Ninja-Squad,項目名稱:globe42,代碼行數:3,代碼來源:authenticated.guard.ts


注:本文中的@angular/router.Router.parseUrl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。