I have an application which uses angular and in the view I call a controller function to hide/show a div but also needs the value from the return of the function. Code is as folowing
<div class="item-icon-right" ng_show="getClass(item.jsonpath) !== ''">
<i class="icon ion-record getClass(item.jsonpath)"></i>
</div>
You see that getClass is called twice for an item. Is it possible to store the value and reuse it?
You can simply store the returned value in new variable and use it for i class:
<div class="item-icon-right" ng_show="(itemClass = getClass(item.jsonpath)) !== ''">
<i class="icon ion-record {{ itemClass }}"></i>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With