hello I wo...">

Knockout interception on anchor label

I have an anchor tag with an icon inside it as follows:

<a> <i class="icon-flip-2"></i> hello </a> 

I would like to replace the welcome text with a related element. Something like:

 <a data-bind="text: myValue"> <i class="icon-flip-2"></i> hello </a> 

The problem is that I lost the element <i class = "icon-flip-2">

I want to save it and be able to bind something to the anchor tag.

Thanks.

Any idea?

+7
source share
3 answers

Use virtual item

 <a> <i class="icon-flip-2"></i> <!-- ko text: myValue --><!-- /ko --> </a> 

or a <span>

 <a> <i class="icon-flip-2"></i> <span data-bind="text: myValue, if: myValue().length > 0"></span> </a> 
+11
source

Place the text inside the span inside the tag and bind its span text property.

0
source

I will be tempted to place text between:

 <a> <i class="icon-flip-2"></i> <span data-bind="text: myValue"></span> </a> 
0
source

All Articles