Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Please always try to use model rather than using primitive types while using the ng-model because of the javascript's prototypical hierarchies.</p> <pre><code>angular.module('facet.directives').directive('paginate', function () { return { restrict: 'E', replace: true, template: '&lt;div class="pull-right discovery-pagination" ng-if="(totalPages !== undefined) &amp;&amp; (totalPages &gt; 0)"&gt;' + '&lt;span class="left-caret hoverable" ng-click="changePage(current-1)" ng-show="current &gt; 1"&gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;Page' + '&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;input type="number" ng-model="current.paging" class="pagination-input" ng-keypress="enterPage($event)"/&gt; of' + '&amp;nbsp;&amp;nbsp;&amp;nbsp;{{totalPages}}&amp;nbsp;&amp;nbsp;' + '&lt;span class="right-caret hoverable" ng-click="changePage(current+1)" ng-show="current &lt; totalPages"&gt;&lt;/span&gt;' + '&lt;/div&gt;', scope: { goToPage: '&amp;', totalPages: '=', totalHits: '=' }, link: function(scope) { scope.current = {paging:1}; scope.changePage = function(page) { scope.current.paging = page; window.scrollTo(0, 0); scope.goToPage({ page: page }); }; scope.enterPage = function(event) { if (event.keyCode == 13) { scope.changePage(scope.current.paging); } }; } }; }); </code></pre> <p>Hope this will solve your problem :)</p> <p>For detail about this, please go through <a href="https://github.com/angular/angular.js/wiki/Understanding-Scopes" rel="nofollow noreferrer">Understanding-Scopes</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload