Pedro Garcia
Pedro Garcia

Reputation: 61

How to send a string in route parameter? [Angular-Dart]

This is the route configuration:

const Route(path: '/kanji_list/:type/:value', name: 'List', component: KanjiList),

If I use only numbers in my route link, Angular will work:

[routerLink]="['List', {type: 5, value: 3}]

But I want to send a string as a parameter, like this:

[routerLink]="['List', {type: "jlpt", value: 5}]

But it doesn't work. Is it possible to send a string?

Upvotes: 0

Views: 572

Answers (1)

Pedro Garcia
Pedro Garcia

Reputation: 61

It was a syntax error as Christian Amani pointed out. I was using double quotes when Angular accepts single quotes syntax inside a map or list in the template. So changing this:

[routerLink]="['List', {type: "jlpt", value: 5}]"

To this:

[routerLink]="['List', {type:'jlpt', value: 5}]"

Fixed the problem.

Upvotes: 1

Related Questions