Here is my current implementation:
<div class="outer-class" ng-repeat="item in items">
<div class="inner-class" ng-if="isShow">
<div class="inner-class-1">{{item}}</div>
</div>
<div ng-if="!isShow" class="inner-class-1">{{item}}</div>
</div>
While the above code is functional, it contains a significant amount of repetition:
- The
ng-if
directive is typed out twice (ng-switch
isn't a viable alternative since it introduces another element) - The
segment is duplicated to prevent the encapsulating of data when the<div ng-if="!isShow" class="inner-class-1">{{item}}</div>
ng-if
condition is false.
I am contemplating whether there is a more effective way to rewrite the code while achieving the same outcome.