2017-02-07 15 views
8

Uygulamamda yönlendirme yoluyla bir model başlatmaya çalışıyorum. Her şey işe yarayacak gibi görünüyor, ancak URL'ye çözülmesini engelleyen ek bir eğik çizgi eklendi. URL aşağıdaki gibi görünmelidir (ve elle girerseniz çalışır) ...Yönlendiriciyi yönlendirici yoluyla adlandırınLink ekler "/"

/accounts(modal:accounts/1/edit) 

ama ... Bu yerine (baz url ve çıkış hedef arasındaki çizgi fark)

alıyorum baz etiketi ayarlanır
/accounts/(modal:accounts/1/edit) 

...

<head> 
    <meta charset="utf-8"> 
    <title>myApp</title> 
    <base href="/"> 
    ... 
</head> 

İşte benim yönlendirme yapılandırma var (hesaplar-routing.module.ts)

const ACCOUNT_ROUTES: Routes = [ 
    { 
    path: 'accounts', 
    component: AccountsIndexComponent 
    },{ 
    path: 'accounts/new', 
    component: AccountsNewComponent 
    },{ 
    path: 'accounts/:id', 
    component: AccountsShowComponent 
    },{ 
    path: 'accounts/:id/edit', 
    component: AccountsEditComponent, 
    outlet: 'modal' 
    } 
]; 

Ve çıkış (app.component.html)

<router-outlet></router-outlet> 
<router-outlet name="modal"></router-outlet> 

Ve linke ...

<a [routerLink]="[{ outlets: { modal: ['accounts', account.id, 'edit'] } }]">Edit</a> 

ben eksik? Proje, [email protected] ve [email protected] ve [email protected] kullanılarak oluşturulmuştur.

FWIW, burada

failed routing attempt

+0

'index.html 'dosyasına' 'eklediniz mi? – unitario

+0

yup, '' etiketi – Brian

+0

'' -tag'ın ilk çocuğu olarak? Probleminizin yolların nasıl çözüldüğü ile ilgili olabileceğini düşünüyorum. – unitario

cevap

17

düzeltme linke boş göreli yolu tanımlamak oldu ... günlükleri bir ekran görüntüsü var. Beni doğru yönde işaret ettiğin için @unitario'ya teşekkürler!

<a [routerLink]="['', { outlets: { modal: ['accounts', account.id, 'edit'] } }]">Edit</a> 
+0

In our application we have an authentication modal that can open over any view so any initial path caused issues, either by loosing the current route or by adding extra slash. This solved the issue, Thank you! the only thing added is queryParamsHandling="merge" to facilitate passing parameters to the modal and the underlying view '' – Greg

İlgili konular