Angular variable into routerLink












0















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










share|improve this question




















  • 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 need data.id after the route name. That should work.

    – R. Richards
    Nov 28 '18 at 16:09


















0















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










share|improve this question




















  • 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 need data.id after the route name. That should work.

    – R. Richards
    Nov 28 '18 at 16:09
















0












0








0








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










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 need data.id after the route name. That should work.

    – R. Richards
    Nov 28 '18 at 16:09
















  • 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 need data.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














2 Answers
2






active

oldest

votes


















3














There you go.



<a [routerLink]="['/details', data.id]"> Link </a>






share|improve this answer


























  • 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



















2














Parameters go as second item in the array syntax to router link, like this:



[routerLink]="['/details', data.id]


Read more here






share|improve this answer























    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    3














    There you go.



    <a [routerLink]="['/details', data.id]"> Link </a>






    share|improve this answer


























    • 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
















    3














    There you go.



    <a [routerLink]="['/details', data.id]"> Link </a>






    share|improve this answer


























    • 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














    3












    3








    3







    There you go.



    <a [routerLink]="['/details', data.id]"> Link </a>






    share|improve this answer















    There you go.



    <a [routerLink]="['/details', data.id]"> Link </a>







    share|improve this answer














    share|improve this answer



    share|improve this answer








    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



















    • 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













    2














    Parameters go as second item in the array syntax to router link, like this:



    [routerLink]="['/details', data.id]


    Read more here






    share|improve this answer




























      2














      Parameters go as second item in the array syntax to router link, like this:



      [routerLink]="['/details', data.id]


      Read more here






      share|improve this answer


























        2












        2








        2







        Parameters go as second item in the array syntax to router link, like this:



        [routerLink]="['/details', data.id]


        Read more here






        share|improve this answer













        Parameters go as second item in the array syntax to router link, like this:



        [routerLink]="['/details', data.id]


        Read more here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 28 '18 at 16:15









        AragornAragorn

        2,56911430




        2,56911430






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

            Calculate evaluation metrics using cross_val_predict sklearn

            Insert data from modal to MySQL (multiple modal on website)