2013-12-09 41 views
28

Bunları durumda olabilir:UI yönlendirici URL'lerde sorgu dizesi parametresi?

Müşteri sorgu dizesi çekilir, ve ben quotes.new devlet sola am URL'yi /quotes/new?customer=123 isabet
.state('quotes', { 
    abstract: true, 
    url: '/quotes' 
}) 
.state('quotes.new', { 
    url: '/new', 
    templateUrl: 'views/quote-form.html', 
    controller: 'QuoteFormCtrl' 
}) 
.state('quotes.new.customer', { 
    url: '?customer', 
    templateUrl: 'views/quote-form.html', 
    controller: 'QuoteFormCtrl' 
}) 

?.

Bana en anlamlı olan şey,'un quotes.new durum tanımına eklenmesidir, ancak bu bana hem url hem de params belirtmemi bildiren bir hata veriyor.

Yapmaya çalıştığım her şey çok takdir edilecektir.

cevap

45

Bunu, sizin customer sorgu parametresi dahil etmek url dize özelliğini değiştirmek gerekir:

.state('mystate', { 
    url: '/myState?paramOne&paramTwo 
    //... 
}); 

the docs

bakınız:

.state('quotes.new', { 
    url: '/new?customer', 
    templateUrl: 'views/quote-form.html', 
    controller: 'QuoteFormCtrl' 
}); 

Birden çok parametre bir & ile ayırarak eklenebilir

+0

Teşekkürler. Yaptığımdan daha basit olması gerektiğini biliyordum. – kbanman

+8

Bu, $ state.go ile nasıl çalışır? '$ state.go ('quotes.new', {customer: 'dave'})'? – connorbode

+1

[yup] (http://angular-ui.github.io/ui-router/site/#/api/ui.router.state.$state#go) – calebboyd