本文整理匯總了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);
});
}
};
}
示例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)();
}
},
示例3:
scope.$on('$destroy', () => {
$document.off('click touchstart', handler);
});