0

I want to send parameter with default route in durandal js.

 { route: '', title: 'Welcome', moduleId: 'viewmodels/welcome', nav: true },

like

{ route: 'test/:id', moduleId: 'viewmodels/test', nav: true },

But unfortunately I can't do it. I want to set the url as 'http://domainname.com/123' where '123' is the paramater(id). 'http://domainname.com/#test/123' is working for me according to the second route. Can anyone please help me.?

Midhuna
  • 4,523
  • 4
  • 21
  • 22
  • 4
    You can write a route like: `{ route: '(:id)', title: 'Welcome', moduleId: 'viewmodels/welcome', nav: true }` however it will only work urls like `http://domainname.com/#123` and not with `http://domainname.com/123`. In order to work with your example you need to fix this in your webserver/webapplication level and cannot be done only in durandal.... – nemesv May 15 '14 at 06:19
  • If the value is a default, why do you need to pass it? You can infer the value from the absence of a parameter. – Peter Wone Oct 01 '14 at 09:30

2 Answers2

2

As far as I know, this is not possible - and it's by design. You can refer to both Durandal's own documentation on the router and also this post in Google Groups where Rob Eisenberg (creator of Durandal) has provided a show answer on the subject himself.

aup
  • 800
  • 7
  • 19
0

Well, actuallly you can handle this if u make your default or home page, an inner page . . . i've done this before and it works.

i know this is not the behavior or the expected approach, but since an argument (or param) belong to something, you should expect a route in order to send a param to it.

Felipe Quirós
  • 430
  • 5
  • 15