本文整理汇总了TypeScript中angular.forEach函数的典型用法代码示例。如果您正苦于以下问题:TypeScript forEach函数的具体用法?TypeScript forEach怎么用?TypeScript forEach使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了forEach函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
this.uploadFileToUrl = function (files: any, uploadUrl: any, successFn: any, errorFn: any, params: any) {
var fd = new FormData();
var arr = files;
if(!_.isArray(files)) {
arr = [files];
}
if (arr.length > 1) {
angular.forEach(arr, function(file: any, index: any) {
index += 1;
fd.append('file' + index, file);
});
} else {
fd.append('file', arr[0]);
}
if (params) {
angular.forEach(params, function (val: any, key: any) {
fd.append(key, val);
})
}
$http.post(uploadUrl, fd, {
transformRequest: angular.identity,
headers: {'Content-Type': undefined}
})
.then(function (data: any) {
if (successFn) {
successFn(data)
}
},function (err: any) {
if (errorFn) {
errorFn(err)
}
});
}
示例2: function
angular.forEach(rows, function (row:any, i:any) {
if (columns.length == 0) {
angular.forEach(row, function (val:any, name:any) {
var displayName = name;
if (name.indexOf('.') >= 0) {
displayName = name.substring(name.indexOf('.') + 1);
}
if (hideColumns && (_.contains(hideColumns, displayName) || _.contains(hideColumns, name))) {
}
else {
displayColumns.push(displayName)
columns.push(name);
}
});
}
if (transformFn != null) {
transformFn(row, columns, displayColumns);
}
angular.forEach(displayColumns, function (displayColumn:any, i:any) {
row[displayColumn] = row[columns[i]];
});
});
示例3: initializeModule
export function initializeModule(target: Function, options: ModuleOptions) {
const ngMod = createModule(target, options.dependencies, name(target, options));
// Register values and constants
ng.forEach(options.values, (val, key) => ngMod.value(key, val));
ng.forEach(options.constants, (val, key) => ngMod.constant(key, val));
}
示例4: function
var f = function (element) {
if (element.data().hasOwnProperty('$scope')) {
scopes++;
angular.forEach(element.data().$scope.$$watchers, function () {
count++;
});
}
angular.forEach(element.children(), function (childElement) {
f($(childElement));
});
};
示例5: f
const f = element => {
if (element.data().hasOwnProperty('$scope')) {
scopes++;
angular.forEach(element.data().$scope.$$watchers, () => {
count++;
});
}
angular.forEach(element.children(), childElement => {
f($(childElement));
});
};
示例6: function
this.cancelPendingHttpRequests = function () {
angular.forEach($http.pendingRequests, function (request: any) {
if (request.cancel && request.timeout) {
request.cancel.resolve();
}
});
}
示例7: moment
var successFn = (response: any)=> {
var unhealthyFeedNames: any[] = [];
if (response.data) {
angular.forEach(response.data, (feedHealth: any)=> {
if (this.data.feedHealth[feedHealth.feed]) {
angular.extend(this.data.feedHealth[feedHealth.feed], feedHealth);
}
else {
this.data.feedHealth[feedHealth.feed] = feedHealth;
}
if (feedHealth.lastUnhealthyTime) {
feedHealth.sinceTimeString = moment(feedHealth.lastUnhealthyTime).fromNow();
}
if (feedHealth.healthy) {
// AlertsService.removeFeedFailureAlertByName(feedHealth.feed);
}
else {
unhealthyFeedNames.push(feedHealth.feed);
// AlertsService.addFeedHealthFailureAlert(feedHealth);
}
});
//only unhealthy will come back
//if feedName is not in the response list, but currently failed.. remove it
// var failedFeeds = AlertsService.feedFailureAlerts;
// angular.forEach(failedFeeds, function (alert, feedName) {
// if (_.indexOf(unhealthyFeedNames, feedName) == -1) {
// AlertsService.removeFeedFailureAlertByName(feedName);
// }
// });
}
this.data.fetchFeedHealthTimeout();
}
示例8: function
return function (items: any, filterOn: any) {
if (filterOn === false) {
return items;
}
if ((filterOn || angular.isUndefined(filterOn)) && angular.isArray(items)) {
var hashCheck: any = {}, newItems: any[] = [];
var extractValueToCompare = function (item: any) {
if (angular.isObject(item) && angular.isString(filterOn)) {
return item[filterOn];
} else {
return item;
}
};
angular.forEach(items, (item: any)=> {
var valueToCheck, isDuplicate = false;
for (var i = 0; i < newItems.length; i++) {
if (angular.equals(extractValueToCompare(newItems[i]), extractValueToCompare(item))) {
isDuplicate = true;
break;
}
}
if (!isDuplicate) {
newItems.push(item);
}
});
items = newItems;
}
return items;
};