dart - AngularDart routes: Optional parameter -


is possible setup optional route parameters without setting secondary route? want set simple rest type interface path defined such:

reports/:reporttype/:reportid

navigating reports/:reporttype allow listing completed reports of specified type , navigating full path bring specific report. first portion have working fine, i'm unable determine how make last segment optional.

using following route definition, enter method called when parameters specified:

void routesinit(router router, routeviewfactory view) {   view.configure({     'report' : ngroute(         // :rptid cannot null (aka not provided)         path: '/reports/:rpttype/:rptid',         enter: (routeenterevent e) {           print(e.parameters);         })   }); } 

i've tried standard type optional braces around :rptid such parents /reports/:rpttype(/:rptid) , square braces /reports/:rpttype(/:rptid) no avail.

i've tried following:

void routesinit(router router, routeviewfactory view) {   view.configure({     'report' : ngroute(         // :rptid cannot null (aka not provided)         path: '/reports/:rpttype',         enter: (routeenterevent e) {           print(e.parameters);         },         mount: {           'report_type' : ngroute(             path: '/:rptid',             enter: (routeenterevent e) {               print(e.parameters);               print(e.route.parent.parameters);           })         })   }); } 

the problem above both report , report_type enter functions called can't setup views there need kind of check in enter function of report route detect if there child route, , i'm not sure how accomplished either.

is there easier way of specifying optional parameter or should @ changing paths want use mitigate nested/child parameters? (e.g.: use reports/type/:rpttype , reports/single/:rptid)

the solution in case extremely simple. on engineering solution. simple fix, use 2 top-level routes.

void routesinit(router router, routeviewfactory view) {   view.configure({     'report' : ngroute(         path: '/reports/:rpttype',         enter: (routeenterevent e) {           print(e.parameters);       }),     'report_id': ngroute(         path: '/reports/:rpttype/:rptid',         enter: (routeenterevent e) {           print(e.parameters);         })   }); } 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -