<div class="sunti_contain" ng-repeat="sunti in suntis track by $index">
<div class="individual_sunti" ng-click="update_ancestor(sunti)">
<!--needs a unique div#id via angularz-->
<div class="sunti_content" ng-bind="sunti.content"></div>
<div class="sunti_tags" ng-bind="sunti.tags"></div>
<div class="sunti_author" ng-bind="sunti.author"></div>
<div class="sunti_shortid" ng-bind="sunti.short_id"></div>
<div class="sunti_ancestor" ng-bind="sunti.ancestor"></div>
</div>
<div class="sunti_reply_carriage_wrapper">
<div class="sunti_reply_carriage" ng-show="!sunti.descendents.length">
<div class="individual_sunti reply_carriage_sunti" ng-repeat="descendent in sunti.descendents">
<div class="sunti_content" ng-bind="descendent.content"></div>
<div class="sunti_tags" ng-bind="descendent.tags"></div>
<div class="sunti_author" ng-bind="descendent.author"></div>
<div class="sunti_shortid" ng-bind="descendent.short_id"></div>
</div>
</div>
</div>
</div>
Я хочу показать только div.sunti_reply_carriage, если в ng-repeat есть какие-либо потомки. Если нет потомков, я не хочу, чтобы div sunti_reply_carriage появлялся вообще. Однако ng-show="!sunti.descendents.length"
не работает, по-видимому, потому, что он находится только снаружи/перед повторением ng, который ссылается descendents in sunti.descendents
Угловое условное отображение div в гнезде ng-repeat
Как это сделать?
Вы можете попробовать с нг-шоу = "sunti.descendents.length> 0" –
Спасибо Я сделал 'нг-если = "sunti.descendents.length> 0" 'в моей обертке div, и это сделало трюк! =) Добавьте его в качестве ответа, и вы получите его (если вы этого захотите) – sova
Вы также можете использовать ng-if = "sunti.descendents.length", так как любое число, отличное от 0, всегда будет равно true –