arrays - How to set dynamic limit in ng-repeat angular js -


how set dynamic limit in ng-repeat ? want set limit if window width less 750 px set limit 1.

here controller function:

$scope.$watch('window.innerwidth', function() {     $scope.wsizewindow = window.innerwidth;      if($scope.wsizewindow < 750) {         $scope.limit = 0;     } else {     }      console.log($scope.wsizewindow); }); 

here html:

<flex-slider slider-id=""              flex-slide="responsibilities in roles.responsibilities track $index | limitto: limit" animation="slide"              animation-loop="false" item-width="350" item-margin="1" keyboard="false"              as-nav-for="#slider" slideshow="false" control-nav="false">         <li class="col-sm-3" ng-if="responsibilities.responsibilityname!=''">          <div class="new-box" ng-if="$index!=roles.responsibilities.length-1">             <div class="panel-heading1">responsibility</div>             <div class="col-xs-12 col-sm-12">                 <div class="strike" >                     <span >{{responsibilities.responsibilityname}}</span>                 </div>             </div>             <div class="col-xs-12 col-sm-12 box">                 <div class="form-group list"  mb-scrollbar="scrollbar('vertical', true)">                     <div class="panel panel-default" style="cursor: pointer;" ng-click="invokereviewprocess(departments,roles,responsibilities,processes,iscompadmin);" ng-repeat="processes in responsibilities.processes">                         <span class="id">{{processes.name}}</span>                     </div>                 </div>                 <div align="center" id="addprocesslink" ng-if="isadmin === true && isgraph">                     <a class="primary-link" ng-click="addprocess(departments.id,roles.id,responsibilities.id)" href="#"> add process</a>                 </div>             </div>         </div>     </li> </flex-slider> 

i want set limit here:

responsibilities in roles.responsibilities track $index | limitto: limit. 

give me suggestions. new angularjs. thanks.

use function defined in controller:

responsibilities in roles.responsibilities track $index | limitto: (setlimit()) 

in controller:

$scope.setlimit = function() {     //check if window width less 750, if yes, return 1 else other limit } 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -