2015-09-06 10 views
12

मैं कोणीय 2 डार्ट में राउटर और रूटपेराम का उपयोग कर रहा हूं।मैं कोणीय 2 डार्ट का उपयोग कर पेज रीलोड पर रूट पैराम्स का समर्थन कैसे करूं?

@RouteConfig(const [ 
    const Route(path: '/', component: ViewLanding, as: 'home'), 
    const Route(path: '/landing', component: ViewLanding, as: 'landing'), 
    const Route(path: '/flights', component: ViewFlights, as: 'flights'), 
    const Route(path: '/picker/:cityDepart/:cityArrival/:dateDepart/:dateArrival/', component: ViewFlights, as: 'picker'), 
    const Route(path: '/order/:id/:level/:dateDepart/:dateArrival/', component: ViewOrder, as: 'order'), 
    const Route(path: '/order/complete', component: ViewComplete, as: 'orderComplete') 
]) 

// आवेदन प्रवेश बिंदु:

void main() { 
    print('-- Main.dart 2 --'); 
    bootstrap(Tickets, [ 
    routerInjectables, 
    client_classes, 
    // The base path of your application 
    bind(APP_BASE_HREF).toValue('/'), 
    // uncomment this if you want to use '#' in your url 
    bind(LocationStrategy).toClass(HashLocationStrategy) 
    ]); 
} 

इस रूटर-आउटलेट/रूटर-लिंक के साथ ठीक काम करता है/router.navigate

हालांकि

मेरे मार्गों निम्न हैं , पृष्ठ रीलोड पर - मुझे पैरा के साथ मार्गों के लिए सकारात्मक मिलान नहीं मिलता है। आईई: अगर मैं http://localhost:8080/#/picker/SAN/SFO/2015-01-01/2015-04-02 रीफ्रेश करता हूं - मैं बिना किसी बच्चे के मार्ग के माता-पिता के दृश्य पर जाता हूं। यह लक्षण पैराम के साथ किसी भी मार्ग के लिए सच है।

करने के लिए या करने के लिए ताज़ा सीधे नेविगेट: http://localhost:8080/#/flights/ - काम करता है के रूप में उम्मीद - ViewFlights घटक instantiated है

लक्षण: पैरामीटर वाला मार्ग विफल रहता है।

प्रश्न: मैं कैसे ताज़ा करने पर मापदंडों

लिंक के साथ काम करने के लिए मार्ग विन्यास को परिभाषित करते हैं: https://github.com/rightisleft/web_apps_dart/blob/angular2/web/main.dart https://github.com/rightisleft/web_apps_dart/blob/angular2/lib/client/tickets.dart

+0

आप इस पर एक समाधान के साथ खत्म किया था के बाद? – Pacane

+0

यह अल्फा 31 में तय किया जाना था (देखें [मुद्दा] (https://github.com/angular/angular/issues/2920) और [फिक्स] (https://github.com/angular/angular/commit/ c177d88)), हालांकि यह केवल यूआरएल के लिए ही दिखता है, पैराम नहीं। यह समीक्षा के लिए अपने गिट में जारी किया जाना चाहिए। –

+0

मैंने अभी इसे अल्फा 37 –

उत्तर

0

अगर मैं आपके सवाल का सही ढंग से समझ, आप की सदस्यता के लिए की जरूरत है नए घटक के साथ पुराने पैरा को अपडेट करने के लिए अपने घटक में राउटर ईवेंट, और फिर अपना यूआई अपडेट करें।

मुझे लगता है कि जब आप यूआरएल http://localhost:8080/#/picker/SAN/SFO/2015-01-01/2015-04-02 खोलते हैं तो आपकी समस्या तब होती है, और फिर http://localhost:8080/#/picker/SAN/SFO पर नेविगेट होती है। आप जो करते हैं वह मार्ग बदल रहा है, लेकिन घटक पहले से ही तत्काल है, जिसका अर्थ है कि नया पैरा अपडेट नहीं किया जाएगा (न ही हटाया जाएगा)। क्या मैं आमतौर पर करते हैं अपने माता पिता के घटक

कोणीय 5

constructor(private router:Router){ 
// Subscribe to the router events. 
// It may be a good idea to assign this subscription to a variable, and then do an unsubscribe in your ngOnDestroy(). 
this.router.events.subscribe(event=>{ 
    if(event instanceof ActivationEnd){ 
    var cityDepart = event.snapshot.params["cityDepart"]; 
    var cityArrival = event.snapshot.params["cityArrival"]; 
    var dateDepart = event.snapshot.params["dateDepart"]; 
    var dateArrival = event.snapshot.params["dateArrival"]; 
    // do some logic 
    } 
}); 
} 
संबंधित मुद्दे