So, I have a button called “show more” that will increase the number of items in the list as soon as it reaches the maximum number of lists that I want to change, to the “show less” button, which returns the list back to its default value.
I use ng-if to determine which button will be shown, and ng-click to determine the action. When used together, ng-click stops working and nothing happens when I click.
here is the html that I wrote in jade, feedLimit is the number of elements displayed in the list.
button.btn.btn-primary.btn-block.btn-sm.btn-outline(type='button')(ng-if= "feedLimit < notifications.all.length", ng-click="feedLimit = feedLimit + 4") span(translate) Show More button.btn.btn-primary.btn-block.btn-sm.btn-outline(type='button')(ng-if= "feedLimit >= notifications.all.length", ng-click="feedLimit = 4") span(translate) Show Less
I tried using ng-show and ng-hide, and they work fine, but it is better to use ng-if, there is no animation and it is faster.
Here is another html output of the show button
<button type="button" ng-if="feedLimit < notifications.all.length" ng-click="feedLimit = feedLimit + 4" class="btn btn-primary btn-block btn-sm btn-outline ng-scope" style=""><span class="ng-scope">Show More</span></button>
source share