本文整理汇总了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;
}
});
示例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);
}
});
示例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;
}
}
}
});
示例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');
}
示例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');
}
示例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 );
}
示例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
}
});
示例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 );
}
示例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();
});
示例10: canActivate
canActivate(): boolean | UrlTree {
return this.currentUserService.isLoggedIn() || this.router.parseUrl('/login');
}