Search code examples
angularjsionic-frameworkionic-view

Hide a <div> if the fiel is empty


I have this with a field. I want if the fild is empty, don´t show this div.

<div class="item noborder">
   <img class="full-image" image-lazy-loader="lines" image-lazy-src="{{restaurantes.fornecedor_visual_foto2}}" />
</div>

How I can do it?

I tried:

<div ng-hide='{{restaurantes.fornecedor_visual_foto1}} = '' '>
   <div class="item noborder"><img class="full-image" image-lazy-loader="lines" image-lazy-src="{{restaurantes.fornecedor_visual_foto1}}"  /></div>
</div>              

But it´s wrong...


Solution

  • It may also come back as undefined or null. You may want to try.

    {{restaurantes.fornecedor_visual_foto1}} === '' || {{restaurantes.fornecedor_visual_foto1}} == undefined || {{restaurantes.fornecedor_visual_foto1}} == null

    However I'd put this in my controller and call a function which would return a bool to keep the html clean