在 ng-class 中使用 ngDisabled

Use of ngDisabled in ng-class

看ui-bootstrap分页的模板,不明白ng-classngDisabled的用法。我正在寻求一些帮助来理解这一点。

我查看了 'PaginationController' 并且 ngDisabled 不是范围 属性,它是指 ng-disabled 指令吗?

<ul class="pagination"> 
  <li ng-if="::boundaryLinks" ng-class="{disabled: noPrevious()||ngDisabled}" class="pagination-first"><a href ng-click="selectPage(1, $event)">{{::getText('first')}}</a></li> 
  <li ng-if="::directionLinks" ng-class="{disabled: noPrevious()||ngDisabled}" class="pagination-prev"><a href ng-click="selectPage(page - 1, $event)">{{::getText('previous')}}</a></li> 
  <li ng-repeat="page in pages track by $index" ng-class="{active: page.active,disabled: ngDisabled&&!page.active}" class="pagination-page"><a href ng-click="selectPage(page.number, $event)">{{page.text}}</a></li> 
  <li ng-if="::directionLinks" ng-class="{disabled: noNext()||ngDisabled}" class="pagination-next"><a href ng-click="selectPage(page + 1, $event)">{{::getText('next')}}</a></li> 
  <li ng-if="::boundaryLinks" ng-class="{disabled: noNext()||ngDisabled}" class="pagination-last"><a href ng-click="selectPage(totalPages, $event)">{{::getText('last')}}</a></li> 
</ul> 

编辑

正如 Shamal 所指出的,ngDisabled 在分页指令的范围内:

.directive('pagination', ['$parse', 'paginationConfig',   function($parse, paginationConfig) {
return {
    restrict: 'EA',
    scope: {
      totalItems: '=',
      firstText: '@',
      previousText: '@',
      nextText: '@',
      lastText: '@',
      ngDisabled:'='
    },
...

是的 ngDisabled 来自指令。

如果在指令中将 ng-disabled 设置为 true,则在 noPrevious() returns false 时禁用 class 将适用。您可以有条件地将 class 应用于 li.

.directive('myDirective', function() {
  return {
    restrict: 'E',
    scope: {
      ngDisabled: '='
    },
    templateUrl: 'template.html'
  };
});

<my-directive ng-disabled="true"></my-directive>