1

I have this router link:

<a [routerLink]="['RepairReturnListing', {country: someVal}]">Test</a>

In my component I define someVal like this:

export class RepairReturnCountByCountry {
   ...
   someVal: number = 1;
   ...
}

When the value is 1 I get this URL:

http://localhost:54675/repairReturnListing?country

Notice, no equals sign and no value.
I display the value in a div and it works as expected.

<div>{{someVal}}</div>

If I change it to anything other than one (even -1) I get a valid URL:

http://localhost:54675/repairReturnListing?country=0
http://localhost:54675/repairReturnListing?country=2
http://localhost:54675/repairReturnListing?country=777
http://localhost:54675/repairReturnListing?country=-1

If I remove someVal from the component I get:

http://localhost:54675/repairReturnListing?country=null

I change someVal to a string but I get the same results:

 someVal: string = '1';

Here is my routeConfig:

 @RouteConfig([
        { path: '/repairReturnListing', name: 'RepairReturnListing', component: ListingComponent, useAsDefault: false }
])
Don Chambers
  • 3,798
  • 9
  • 33
  • 74
  • 1
    There [was an issue](https://github.com/angular/angular/issues/5346) when using the number 1 as parameter but it was fixed, what angular2 version are you using? – Eric Martinez Mar 16 '16 at 21:11
  • I'm was using 2.0.0-beta.0. I upgraded to 2.0.0-beta.9 but now I can't build. I'l going through the error messages now. When was it fixed? It looks like .9 from that link but I'm not sure. – Don Chambers Mar 17 '16 at 00:00
  • The errors may be another question, I can confirm that the problem exists in beta.0, I upgraded to beta.9 and it works correctly Check this [plnkr](http://plnkr.co/edit/5RU8DzpZynxogWkfOiWe?p=preview) (I took it from the issue I referenced). – Eric Martinez Mar 17 '16 at 00:07
  • After upgrading I get erorrs like: angular2/src/router/directives/router_link"' has no exported member 'RouterLink' is router.d.ts and Cannot find name 'SetConstructor'. in collection.d.ts – Don Chambers Mar 17 '16 at 00:11
  • that's another question. Make another or google them. After you solved those errors see if this error persists, if it doesn't you can come over here and answer yourself. It seems like you have wrong paths over there (you shouldn't import RouterLink from there but from `angular2/router`). – Eric Martinez Mar 17 '16 at 00:16

0 Answers0