Angular variable into routerLink
I'm trying to pass an id in my routerLink, how could I concatenate it?
<a routerLink="['/details', {{data.id}}]"> </a> doesnt work.
Do you have solutions?
Thanks in advance
angular routerlink
add a comment |
I'm trying to pass an id in my routerLink, how could I concatenate it?
<a routerLink="['/details', {{data.id}}]"> </a> doesnt work.
Do you have solutions?
Thanks in advance
angular routerlink
1
I guess you have tried to put code inside post? It's not showing. Update it please.
– Oen44
Nov 28 '18 at 16:01
Code please..and concatenate id with what? path?
– Aragorn
Nov 28 '18 at 16:03
Sorry I forgot to put it between quotes
– antoine-coulon
Nov 28 '18 at 16:07
Remove the curly brackets ({{ }}
) in what you have now. You just needdata.id
after the route name. That should work.
– R. Richards
Nov 28 '18 at 16:09
add a comment |
I'm trying to pass an id in my routerLink, how could I concatenate it?
<a routerLink="['/details', {{data.id}}]"> </a> doesnt work.
Do you have solutions?
Thanks in advance
angular routerlink
I'm trying to pass an id in my routerLink, how could I concatenate it?
<a routerLink="['/details', {{data.id}}]"> </a> doesnt work.
Do you have solutions?
Thanks in advance
angular routerlink
angular routerlink
edited Nov 28 '18 at 16:06
antoine-coulon
asked Nov 28 '18 at 15:59
antoine-coulonantoine-coulon
227
227
1
I guess you have tried to put code inside post? It's not showing. Update it please.
– Oen44
Nov 28 '18 at 16:01
Code please..and concatenate id with what? path?
– Aragorn
Nov 28 '18 at 16:03
Sorry I forgot to put it between quotes
– antoine-coulon
Nov 28 '18 at 16:07
Remove the curly brackets ({{ }}
) in what you have now. You just needdata.id
after the route name. That should work.
– R. Richards
Nov 28 '18 at 16:09
add a comment |
1
I guess you have tried to put code inside post? It's not showing. Update it please.
– Oen44
Nov 28 '18 at 16:01
Code please..and concatenate id with what? path?
– Aragorn
Nov 28 '18 at 16:03
Sorry I forgot to put it between quotes
– antoine-coulon
Nov 28 '18 at 16:07
Remove the curly brackets ({{ }}
) in what you have now. You just needdata.id
after the route name. That should work.
– R. Richards
Nov 28 '18 at 16:09
1
1
I guess you have tried to put code inside post? It's not showing. Update it please.
– Oen44
Nov 28 '18 at 16:01
I guess you have tried to put code inside post? It's not showing. Update it please.
– Oen44
Nov 28 '18 at 16:01
Code please..and concatenate id with what? path?
– Aragorn
Nov 28 '18 at 16:03
Code please..and concatenate id with what? path?
– Aragorn
Nov 28 '18 at 16:03
Sorry I forgot to put it between quotes
– antoine-coulon
Nov 28 '18 at 16:07
Sorry I forgot to put it between quotes
– antoine-coulon
Nov 28 '18 at 16:07
Remove the curly brackets (
{{ }}
) in what you have now. You just need data.id
after the route name. That should work.– R. Richards
Nov 28 '18 at 16:09
Remove the curly brackets (
{{ }}
) in what you have now. You just need data.id
after the route name. That should work.– R. Richards
Nov 28 '18 at 16:09
add a comment |
2 Answers
2
active
oldest
votes
There you go.
<a [routerLink]="['/details', data.id]"> Link </a>
Thanks Oen! All I needed
– antoine-coulon
Nov 28 '18 at 16:17
1
Technically this works but the recommended way is to pass it as the second argument. Please take a look at Aragom's answer.
– James Poulose
Nov 28 '18 at 16:19
1
@JamesPoulose Updated.
– Oen44
Nov 28 '18 at 16:20
add a comment |
Parameters go as second item in the array syntax to router link, like this:
[routerLink]="['/details', data.id]
Read more here
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53523472%2fangular-variable-into-routerlink%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
There you go.
<a [routerLink]="['/details', data.id]"> Link </a>
Thanks Oen! All I needed
– antoine-coulon
Nov 28 '18 at 16:17
1
Technically this works but the recommended way is to pass it as the second argument. Please take a look at Aragom's answer.
– James Poulose
Nov 28 '18 at 16:19
1
@JamesPoulose Updated.
– Oen44
Nov 28 '18 at 16:20
add a comment |
There you go.
<a [routerLink]="['/details', data.id]"> Link </a>
Thanks Oen! All I needed
– antoine-coulon
Nov 28 '18 at 16:17
1
Technically this works but the recommended way is to pass it as the second argument. Please take a look at Aragom's answer.
– James Poulose
Nov 28 '18 at 16:19
1
@JamesPoulose Updated.
– Oen44
Nov 28 '18 at 16:20
add a comment |
There you go.
<a [routerLink]="['/details', data.id]"> Link </a>
There you go.
<a [routerLink]="['/details', data.id]"> Link </a>
edited Nov 28 '18 at 16:19
answered Nov 28 '18 at 16:13
Oen44Oen44
1,8191919
1,8191919
Thanks Oen! All I needed
– antoine-coulon
Nov 28 '18 at 16:17
1
Technically this works but the recommended way is to pass it as the second argument. Please take a look at Aragom's answer.
– James Poulose
Nov 28 '18 at 16:19
1
@JamesPoulose Updated.
– Oen44
Nov 28 '18 at 16:20
add a comment |
Thanks Oen! All I needed
– antoine-coulon
Nov 28 '18 at 16:17
1
Technically this works but the recommended way is to pass it as the second argument. Please take a look at Aragom's answer.
– James Poulose
Nov 28 '18 at 16:19
1
@JamesPoulose Updated.
– Oen44
Nov 28 '18 at 16:20
Thanks Oen! All I needed
– antoine-coulon
Nov 28 '18 at 16:17
Thanks Oen! All I needed
– antoine-coulon
Nov 28 '18 at 16:17
1
1
Technically this works but the recommended way is to pass it as the second argument. Please take a look at Aragom's answer.
– James Poulose
Nov 28 '18 at 16:19
Technically this works but the recommended way is to pass it as the second argument. Please take a look at Aragom's answer.
– James Poulose
Nov 28 '18 at 16:19
1
1
@JamesPoulose Updated.
– Oen44
Nov 28 '18 at 16:20
@JamesPoulose Updated.
– Oen44
Nov 28 '18 at 16:20
add a comment |
Parameters go as second item in the array syntax to router link, like this:
[routerLink]="['/details', data.id]
Read more here
add a comment |
Parameters go as second item in the array syntax to router link, like this:
[routerLink]="['/details', data.id]
Read more here
add a comment |
Parameters go as second item in the array syntax to router link, like this:
[routerLink]="['/details', data.id]
Read more here
Parameters go as second item in the array syntax to router link, like this:
[routerLink]="['/details', data.id]
Read more here
answered Nov 28 '18 at 16:15
AragornAragorn
2,56911430
2,56911430
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53523472%2fangular-variable-into-routerlink%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
I guess you have tried to put code inside post? It's not showing. Update it please.
– Oen44
Nov 28 '18 at 16:01
Code please..and concatenate id with what? path?
– Aragorn
Nov 28 '18 at 16:03
Sorry I forgot to put it between quotes
– antoine-coulon
Nov 28 '18 at 16:07
Remove the curly brackets (
{{ }}
) in what you have now. You just needdata.id
after the route name. That should work.– R. Richards
Nov 28 '18 at 16:09