knockout.js - hide tag with knockoutjs -


need knockout binding. have following tag]

 <a class="link" data-bind="href: url">my url</a> 

what want is, if "url" null or empty, hide tag view of user.

how can this?

you try this:

<a class="link" data-bind="attr: { href: url}, visible: url().length > 0">     url </a> 

or if don't want appear in markup @ all:

<!-- ko if: url().length > 0 -->     <a class="link" data-bind="attr: { href: url}">         url     </a> <!-- /ko --> 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -