当前位置: 首页>>代码示例>>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;未经允许,请勿转载。