How can I add a `/` to an attribute I'm binding data to?

Optiq

I decided to render my links dynamically on my page and previously the links looked like this

<a routerLink="/home" routerLinkActivate="active">Home</a>

Now that I'm binding data to them to populate them dynamically the syntax is now

<a [attr.routerLink]="link.val" *ngFor="let link of linkData">
    {{link.link}}
</a>

I realized the / wouldn't save in the firebase database for obvious reasons when I really thought about it. But now I can't figure out how to get the / in there.

I've tried

"/link.val"
"/+link.val"
"/++link.val"
"/(link.val)"
"/{link.val}"
"(/)link.val"
"(/)+link.val"
"/[link.val]"

as well as a few others I can't think of at the moment and nothing is working. It's possible to do this right? Without it the link won't work.

jonrsharpe

For the binding to work you need a valid template expression. In this case you want to concatenate a literal string with a variable one, so you need:

[attr.routerLink]="'/' + link.val"

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I add an instance attribute in subclass?

From Dev

How can I add dynamically an attribute with VueJS?

From Dev

How can I use the ngClass with data binding?

From Dev

Active Admin - Can I add a Data Attribute to the Form Tag?

From Dev

Rails - how can I add a data attribute to a fields_for select tag

From Dev

Jquery - How can i add a custom data attribute when appending an html element

From Dev

How can I add Multi class binding in Vue2

From Dev

How can I determine the attribute data type of an entity in Core Data?

From Dev

How can I add columns in a data frame?

From Dev

how can i add data to this object in node?

From Dev

How can I add a custom attribute to a <span> and read it in JavaScript?

From Dev

How can I add the 'required' attribute to input on change of textarea?

From Dev

How can I add a new attribute from another table to a serializer?

From Dev

How can I create custom attribute to add a if.bind?

From Dev

How can I add a custom attribute to an address in Magento?

From Dev

How can I add attribute inside an input tag using jQuery?

From Dev

How can I add a new attribute from another table to a serializer?

From Dev

How I can add attribute to certain type of input

From Dev

How can I add an attribute to a database query before returning?

From Dev

How can I add a class, id or attribute to a twig include?

From Dev

How can I put a condition inside a data binding in AngularJS?

From Dev

how can I pass dynamically data to a knockout template binding

From Dev

How can I use a directive in a component with data binding?

From Dev

How can I cache API data in a class attribute?

From Dev

How can I accept a 'dictionary' of data as a custom .NET attribute parameter?

From Dev

how can i get the data-something attribute with angularJS

From Dev

How can I use the HTML data attribute in CSS as a property?

From Dev

How can I get the data-attribute of each element with a function?

From Dev

Why can't I update a data attribute I'm iterating over in jQuery?

Related Related

  1. 1

    How can I add an instance attribute in subclass?

  2. 2

    How can I add dynamically an attribute with VueJS?

  3. 3

    How can I use the ngClass with data binding?

  4. 4

    Active Admin - Can I add a Data Attribute to the Form Tag?

  5. 5

    Rails - how can I add a data attribute to a fields_for select tag

  6. 6

    Jquery - How can i add a custom data attribute when appending an html element

  7. 7

    How can I add Multi class binding in Vue2

  8. 8

    How can I determine the attribute data type of an entity in Core Data?

  9. 9

    How can I add columns in a data frame?

  10. 10

    how can i add data to this object in node?

  11. 11

    How can I add a custom attribute to a <span> and read it in JavaScript?

  12. 12

    How can I add the 'required' attribute to input on change of textarea?

  13. 13

    How can I add a new attribute from another table to a serializer?

  14. 14

    How can I create custom attribute to add a if.bind?

  15. 15

    How can I add a custom attribute to an address in Magento?

  16. 16

    How can I add attribute inside an input tag using jQuery?

  17. 17

    How can I add a new attribute from another table to a serializer?

  18. 18

    How I can add attribute to certain type of input

  19. 19

    How can I add an attribute to a database query before returning?

  20. 20

    How can I add a class, id or attribute to a twig include?

  21. 21

    How can I put a condition inside a data binding in AngularJS?

  22. 22

    how can I pass dynamically data to a knockout template binding

  23. 23

    How can I use a directive in a component with data binding?

  24. 24

    How can I cache API data in a class attribute?

  25. 25

    How can I accept a 'dictionary' of data as a custom .NET attribute parameter?

  26. 26

    how can i get the data-something attribute with angularJS

  27. 27

    How can I use the HTML data attribute in CSS as a property?

  28. 28

    How can I get the data-attribute of each element with a function?

  29. 29

    Why can't I update a data attribute I'm iterating over in jQuery?

HotTag

Archive