當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript angular.IDocumentService類代碼示例

本文整理匯總了TypeScript中angular.IDocumentService的典型用法代碼示例。如果您正苦於以下問題:TypeScript IDocumentService類的具體用法?TypeScript IDocumentService怎麽用?TypeScript IDocumentService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了IDocumentService類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: ClickAnywhereButHere

export function ClickAnywhereButHere(
  $document: IDocumentService,
  $timeout: ITimeoutService
): IDirective {
  'ngInject';

  return {
    restrict: 'A',
    link(scope, element, attr) {
      const handler = (event) => {
        if (!element[0].contains(event.target)) {
          // This fixes an event ordering bug in Safari that can cause closed dialogs to reopen
          $timeout(() => {
            scope.$apply(attr.dimClickAnywhereButHere);
          }, 150);
        }
      };

      $document.on('click touchstart', handler);
      scope.$on('$destroy', () => {
        $document.off('click touchstart', handler);
      });
    }
  };
}
開發者ID:bhollis,項目名稱:DIM,代碼行數:25,代碼來源:click-anywhere-but-here.directive.ts

示例2: function

          onOpen: function ($event) {
            if (scope.config.disabled) {
              $event.prevent();
              return;
            }

            if (hasBeenOpened === false) {
              hasBeenOpened = true;
            }
            filterOptions();

            $document.on('keyup', onEscPressed);

            domDropDownMenu.style.visibility = 'hidden';
            $timeout(function () {
              adjustHeight();
              domDropDownMenu.style.visibility = 'visible';

              if (scope.config.filter.active) {
                // use timeout to open dropdown first and then set the focus,
                // otherwise focus won't be set because iElement is not visible
                $timeout(function () {
                  iElement[0].querySelector('.dropdown-menu input').focus();
                });
              }
            });
            jqWindow.on('resize', adjustHeight);

            if (angular.isFunction(scope.config.dropdown.onOpen)) {
              (scope.config.dropdown.onOpen as any)();
            }
          },
開發者ID:w11k,項目名稱:w11k-select,代碼行數:32,代碼來源:w11k-select.directive.ts

示例3:

 scope.$on('$destroy', () => {
   $document.off('click touchstart', handler);
 });
開發者ID:bhollis,項目名稱:DIM,代碼行數:3,代碼來源:click-anywhere-but-here.directive.ts


注:本文中的angular.IDocumentService類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。