2016-10-12 22 views
6

Yeni Router 3.0.0'da hangi analog deprecated-router yöntemi yöntemi nedir? Yeni yönlendirici bunu yapmak nasılYeni Yönlendirici'de URL yolu oluşturma Angular 2

this._router.generate(['Profile']).urlPath;

: Erken böyle bir şey alabilir?

+0

Ne yapmak gerekiyor? –

+0

@AlexanderCiesielski Somut rota yoluna ihtiyacım var. – Zverit

cevap

2

Bunlar Günter

tarafından başvurulan sayfasından güncel örneklerdir URL'yi

this._router.navigate(/*string|UrlTree); 

sonucu geçmesi veya alabilirsiniz

// create /team/33/user/11 
router.createUrlTree(['/team', 33, 'user', 11]); 

// create /team/33;expand=true/user/11 
router.createUrlTree(['/team', 33, {expand: true}, 'user', 11]); 

// you can collapse static segments like this (this works only with the first passed-in value): 
router.createUrlTree(['/team/33/user', userId]); 

// If the first segment can contain slashes, and you do not want the router to split it, you 
// can do the following: 

router.createUrlTree([{segmentPath: '/one/two'}]); 

// create /team/33/(user/11//right:chat) 
router.createUrlTree(['/team', 33, {outlets: {primary: 'user/11', right: 'chat'}}]); 

// remove the right secondary node 
router.createUrlTree(['/team', 33, {outlets: {primary: 'user/11', right: null}}]); 

// assuming the current url is `/team/33/user/11` and the route points to `user/11` 

// navigate to /team/33/user/11/details 
router.createUrlTree(['details'], {relativeTo: route}); 

// navigate to /team/33/user/22 
router.createUrlTree(['../22'], {relativeTo: route}); 

// navigate to /team/44/user/22 
router.createUrlTree(['../../team/44/user/22'], {relativeTo: route}); 

https://angular.io/docs/ts/latest/api/router/index/Router-class.html#!#createUrlTree-anchor