本文整理汇总了TypeScript中angular.isFunction函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isFunction函数的具体用法?TypeScript isFunction怎么用?TypeScript isFunction使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isFunction函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: watchProps
/**
*
* @param watchDepth (value of HTML watch-depth attribute)
* @param scope (angular scope)
*
* Uses the watchDepth attribute to determine how to watch props on scope.
* If watchDepth attribute is NOT reference or collection, watchDepth defaults to deep watching by value
*/
function watchProps(watchDepth, scope, watchExpressions, listener) {
const supportsWatchCollection = angular.isFunction(scope.$watchCollection);
const supportsWatchGroup = angular.isFunction(scope.$watchGroup);
const watchGroupExpressions = [];
for (const expr of watchExpressions) {
const actualExpr = getPropExpression(expr);
const exprWatchDepth = getPropWatchDepth(watchDepth, expr);
// ignore empty expressions & expressions with functions
if (!actualExpr || actualExpr.match(/\(.*\)/) || exprWatchDepth === 'one-time') {
continue;
}
if (exprWatchDepth === 'collection' && supportsWatchCollection) {
scope.$watchCollection(actualExpr, listener);
} else if (exprWatchDepth === 'reference' && supportsWatchGroup) {
watchGroupExpressions.push(actualExpr);
} else {
scope.$watch(actualExpr, listener, exprWatchDepth !== 'reference');
}
}
if (watchDepth === 'one-time') {
listener();
}
if (watchGroupExpressions.length) {
scope.$watchGroup(watchGroupExpressions, listener);
}
}
开发者ID:grafana,项目名称:grafana,代码行数:40,代码来源:ng_react.ts
示例2: watchProps
/**
*
* @param watchDepth (value of HTML watch-depth attribute)
* @param scope (angular scope)
*
* Uses the watchDepth attribute to determine how to watch props on scope.
* If watchDepth attribute is NOT reference or collection, watchDepth defaults to deep watching by value
*/
function watchProps(watchDepth, scope, watchExpressions, listener) {
const supportsWatchCollection = angular.isFunction(scope.$watchCollection);
const supportsWatchGroup = angular.isFunction(scope.$watchGroup);
const watchGroupExpressions = [];
watchExpressions.forEach(expr => {
const actualExpr = getPropExpression(expr);
const exprWatchDepth = getPropWatchDepth(watchDepth, expr);
if (exprWatchDepth === 'collection' && supportsWatchCollection) {
scope.$watchCollection(actualExpr, listener);
} else if (exprWatchDepth === 'reference' && supportsWatchGroup) {
watchGroupExpressions.push(actualExpr);
} else if (exprWatchDepth === 'one-time') {
//do nothing because we handle our one time bindings after this
} else {
scope.$watch(actualExpr, listener, exprWatchDepth !== 'reference');
}
});
if (watchDepth === 'one-time') {
listener();
}
if (watchGroupExpressions.length) {
scope.$watchGroup(watchGroupExpressions, listener);
}
}
开发者ID:ArcticSnowman,项目名称:grafana,代码行数:37,代码来源:ng_react.ts
示例3: reject
(data) => {
if (!data) {
reject(`Failed to load dashboard categories. Result: ${data}`);
return;
}
let idCounter = 0;
const newCategories: any = [];
for (let category in data) {
if (data.hasOwnProperty(category)) {
let dashboards = data[category];
if (dashboards.length > 0) {
dashboards = dashboards.filter(dash => dash && dash !== '');
const item = {
id: idCounter++,
name: category,
dashboards: dashboards
};
// sort
if (angular.isFunction(this.$izendaDashboardConfig.dashboardToolBarItemsSort))
item.dashboards.sort((item1, item2) => this.$izendaDashboardConfig.dashboardToolBarItemsSort(item1, item2));
newCategories.push(item);
}
}
}
this.categories.onNext(newCategories, this);
resolve(this.categories);
},
开发者ID:izenda,项目名称:resources,代码行数:27,代码来源:dashboard-storage-service.ts
示例4: onButtonClick
/**
* Handle button click.
*/
onButtonClick(button) {
if (!button) return;
if (angular.isFunction(button.callback)) {
button.callback(this.$izendaUtilUiService.dialogBox.checkboxes);
}
this.closeModal();
}
开发者ID:izenda,项目名称:resources,代码行数:10,代码来源:dialog-box-component.ts
示例5: getReactComponent
// get a react component from name (components can be an angular injectable e.g. value, factory or
// available on window
function getReactComponent(name, $injector) {
// if name is a function assume it is component and return it
if (angular.isFunction(name)) {
return name;
}
// a React component name must be specified
if (!name) {
throw new Error('ReactComponent name attribute must be specified');
}
// ensure the specified React component is accessible, and fail fast if it's not
let reactComponent;
try {
reactComponent = $injector.get(name);
} catch (e) {}
if (!reactComponent) {
try {
reactComponent = name.split('.').reduce((current, namePart) => {
return current[namePart];
}, window);
} catch (e) {}
}
if (!reactComponent) {
throw Error('Cannot find react component ' + name);
}
return reactComponent;
}
开发者ID:ArcticSnowman,项目名称:grafana,代码行数:33,代码来源:ng_react.ts
示例6: function
drop: function (event, ui) {
if (angular.isFunction(scope.onDrop)) {
scope.onDrop({
arg0: angular.element(ui.helper).attr('draggable-data-id')
});
}
}
开发者ID:izenda,项目名称:resources,代码行数:7,代码来源:instant-report-field-draggable.ts
示例7: RecursiveDirectiveHelperCompile
compile: function RecursiveDirectiveHelperCompile(element, link) {
// Normalize the link parameter
if (angular.isFunction(link)) {
link = {
post: link
};
}
// Break the recursion loop by removing the contents
var contents = element.contents().remove();
var compiledContents;
return {
pre: (link && link.pre) ? link.pre : null,
/**
* Compiles and re-adds the contents
*/
post: function RecursiveDirectiveHelperCompilePost(scope, element) {
// Compile the contents
if (!compiledContents) {
compiledContents = $compile(contents);
}
// Re-add the compiled contents to the element
compiledContents(scope, function (clone) {
element.append(clone);
});
// Call the post-linking function, if any
if (link && link.post) {
link.post.apply(null, arguments);
}
}
};
}
开发者ID:amuraru,项目名称:grafana,代码行数:33,代码来源:jsontree.ts
示例8:
function getModuleId<T>(value: T): T | string {
if (ng.isFunction(value) && Reflect.get(value, ID_SYMBOL)) {
return Reflect.get(value, ID_SYMBOL) as string;
}
return value;
}
开发者ID:csvn,项目名称:ng-esm,代码行数:7,代码来源:ng.ts
示例9: 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
示例10: UtilService
export function UtilService($window) {
'ngInject';
var Util = {
/**
* Return a callback or noop function
*
* @param {Function|*} cb - a 'potential' function
* @return {Function}
*/
safeCb(cb) {
return (angular.isFunction(cb)) ? cb : angular.noop;
},
/**
* Parse a given url with the use of an anchor element
*
* @param {String} url - the url to parse
* @return {Object} - the parsed url, anchor element
*/
urlParse(url) {
var a = document.createElement('a');
a.href = url;
// Special treatment for IE, see http://stackoverflow.com/a/13405933 for details
if (a.host === '') {
a.href = a.href;
}
return a;
},
/**
* Test whether or not a given url is same origin
*
* @param {String} url - url to test
* @param {String|String[]} [origins] - additional origins to test against
* @return {Boolean} - true if url is same origin
*/
isSameOrigin(url, origins) {
url = Util.urlParse(url);
origins = (origins && [].concat(origins)) || [];
origins = origins.map(Util.urlParse);
origins.push($window.location);
origins = origins.filter(function(o) {
let hostnameCheck = url.hostname === o.hostname;
let protocolCheck = url.protocol === o.protocol;
// 2nd part of the special treatment for IE fix (see above):
// This part is when using well-known ports 80 or 443 with IE,
// when $window.location.port==='' instead of the real port number.
// Probably the same cause as this IE bug: https://goo.gl/J9hRta
let portCheck = url.port === o.port || (o.port === '' && (url.port === '80' || url.port === '443'));
return hostnameCheck && protocolCheck && portCheck;
});
return origins.length >= 1;
}
};
return Util;
}
开发者ID:Ramyajmys,项目名称:EnfrosProj,代码行数:59,代码来源:util.service.ts
注:本文中的angular.isFunction函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论