3
I am using Angularjs in a project where I need to display a list of photos of products registered in the system and my html
is like this:
// Titulo para a área de produtos
<div class="header-products">
<h3>Produtos</h3>
</div>
// Ng-repeat para listar os produtos, somente serão exibidos produtos com foto
<div class="photo" ng-repeat="product in products | limitTo: 3" ng-if="product.imageUrl">
<img ng-src="{{ product.imageUrl }}" alt="{{ product.name }}"
title="{{ product.name }}" ng-if="product.imageUrl" />
</div>
however the div
header-products should only be displayed if at least one products from my list has photo, if there is no photo I do not display this header
. In the list will always have the name of the products but can s er that does not have the photo:
[
{produto: 'lapis', imageUrl: 'url-da-imagem'},
{produto: 'caneta', imageUrl: 'url-da-imagem'},
{produto: 'borracha', imageUrl: ''}
]
How can I do that if mine header
this outside the ng-repeat
?
Hello Felipe, have you tried ng-if? Something like: <div ng-if="checked"></div>
– Emanoel