本文整理汇总了TypeScript中angular.IQService.defer方法的典型用法代码示例。如果您正苦于以下问题:TypeScript IQService.defer方法的具体用法?TypeScript IQService.defer怎么用?TypeScript IQService.defer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular.IQService
的用法示例。
在下文中一共展示了IQService.defer方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: spyOn
spyOn(literatureService, "getLitOrdersByUsername").and.callFake(() => {
const deferred: IDeferred<any> = $q.defer();
deferred.resolve([
{
"LitOrdersID": 8,
"OrderStatus": "Submitted",
"UserName": "siteadmintestcom",
"OrderDate": "2017-02-01T16:20:00",
"OrderNum": 2,
"Revision": 7,
"TotalCost": null,
"GroupName": "SiteAdmin"
},
{
"LitOrdersID": 9,
"OrderStatus": "Completed",
"UserName": "litordertestcom",
"OrderDate": "2017-02-01T16:20:00",
"OrderNum": 3,
"Revision": 1,
"TotalCost": null,
"GroupName": "LitOrder"
}
]);
return deferred.promise;
});
示例2: spyOn
spyOn(literatureService, "getLitItemsForStockist").and.callFake(() => {
const deferred: IDeferred<any> = $q.defer();
deferred.resolve([
{
"LitItemsID": 1,
"ItemName": "Hope Faith & Courage",
"SalePrice": 7.0,
"QuantityInStock": 0,
"QuantityReserved": 0,
"ItemTypeDescription": "Books",
"ImageFilename": "BOOKS_HFC",
"ItemType": "BOOKS",
"Multiple": 1,
"Active": true
},
{
"LitItemsID": 2,
"ItemName": "Hope Faith & Courage 2",
"SalePrice": 7.14,
"QuantityInStock": 231,
"QuantityReserved": 20,
"ItemTypeDescription": "Books",
"ImageFilename": "BOOKS_HFC2",
"ItemType": "BOOKS",
"Multiple": 1,
"Active": true
}
]);
return deferred.promise;
});
示例3: getAllEntityTags
public getAllEntityTags(entityType: string, entityIds: string[]): IPromise<IEntityTags[]> {
if (!entityIds || !entityIds.length) {
return this.$q.when([]);
}
const idGroups: string[] = this.collateEntityIds(entityType, uniq(entityIds));
const succeeded = (val: IEntityTags[]) => val !== null;
const sources = idGroups.map(idGroup => this.retryService.buildRetrySequence<IEntityTags[]>(
() => this.API.one('tags')
.withParams({
entityType: entityType.toLowerCase(),
entityId: idGroup
}).getList(),
succeeded, 1, 0)
);
const result: IDeferred<IEntityTags[]> = this.$q.defer();
this.$q.all(sources).then(
(entityTagGroups: IEntityTags[][]) => {
const allTags: IEntityTags[] = this.flattenTagsAndAddMetadata(entityTagGroups);
result.resolve(allTags);
})
.catch(() => {
this.$exceptionHandler(new Error(`Failed to load ${entityType} entity tags; groups: \n${idGroups.join('\n')}`));
result.resolve([]);
});
return result.promise;
}
示例4: spyOn
spyOn(loginService, "attemptLogin").and.callFake(() => {
const deferred: IDeferred<ILoginError> = $q.defer();
deferred.reject({data: {
error: "invalid_something"
}});
return deferred.promise;
});
示例5: getAllEntityTags
public getAllEntityTags(entityType: string, entityIds: string[]): IPromise<IEntityTags[]> {
if (!entityIds || !entityIds.length) {
return this.$q.when([]);
}
const idGroups: ICollatedIdGroup[] = this.collateEntityIds(entityType, entityIds);
const succeeded = (val: IEntityTags[]) => val !== null;
const sources = idGroups.map(idGroup => this.retryService.buildRetrySequence<IEntityTags[]>(
() => this.API.one('tags')
.withParams({
entityType: entityType.toLowerCase(),
entityId: idGroup.entityId,
maxResults: idGroup.maxResults,
}).getList(),
succeeded, 1, 0)
);
const result: IDeferred<IEntityTags[]> = this.$q.defer();
this.$q.all(sources).then(
(entityTagGroups: IEntityTags[][]) => {
const allTags: IEntityTags[] = this.flattenTagsAndAddMetadata(entityTagGroups);
result.resolve(allTags);
})
.catch(() => {
result.resolve([]);
});
return result.promise;
}
示例6: spyOn
spyOn(subPageService, "getSubpages").and.callFake(() => {
const deferred: IDeferred<Array<IPageWithContent>> = $q.defer();
deferred.resolve([
{
CAPagesID: 1,
PageName: "page",
PageTitle: "title",
PageContent: "content",
Status: "ACTIVE",
Revision: 1,
StatusDate: "2017-08-15 21:58",
ContentType: "R",
ImageFilename: "page.png"
},
{
CAPagesID: 2,
PageName: "page 2",
PageTitle: "title 2",
PageContent: "content 2",
Status: "ACTIVE",
Revision: 2,
StatusDate: "2017-08-15 21:59",
ContentType: "R",
ImageFilename: "page2.png"
}]);
return deferred.promise;
});
示例7: getProfilePictureUrl
public getProfilePictureUrl(userId) {
const deferred = this.$q.defer();
deferred.resolve("https://scontent.xx.fbcdn.net/hprofile-xpa1/v/t1.0-1/" +
"c12.0.50.50/p57x57/114âŚ_8891337119643731696_n.jpg?" +
"oh=4541774c11459787bb5d9ad23d059770&oe=5798CB9E");
return deferred.promise;
}
示例8: spyOn
spyOn(manageInventoryService, "getLitItems").and.callFake(() => {
const deferred: IDeferred<any> = $q.defer();
deferred.resolve([
{
LitItemsID: 1,
ItemName: "Hope Faith & Courage",
SalePrice: 7.0,
QuantityInStock: 0,
QuantityReserved: 0,
ItemTypeDescription: "Books",
ImageFilename: "BOOKS_HFC",
ItemType: "BOOKS",
Multiple: 1,
Active: true
},
{
LitItemsID: 2,
ItemName: "Hope Faith & Courage 2",
SalePrice: 7.14,
QuantityInStock: 231,
QuantityReserved: 20,
ItemTypeDescription: "Books",
ImageFilename: "BOOKS_HFC2",
ItemType: "BOOKS",
Multiple: 1,
Active: true
}
]);
return deferred.promise;
});
示例9: spyOn
spyOn(dataService, "getData").and.callFake(() => {
const deferred: IDeferred<any> = $q.defer();
deferred.resolve({
Environment: "Debug",
Version: "3.7.0"
});
return deferred.promise;
});