如何将JavaScript代码转换为Promise,全部输入类型脚本
发布时间:2022-06-23 01:48:29 300
相关标签: # 前端
这是我的项目代码,我需要将它从AngularJs迁移到Angular2+,这是JS中的服务文件,需要在TS服务文件上迁移
function initRegionSettings() {
var promises = {};
var dcaRegionSettingsPromise = $q.defer();
promises.appSettings = AppSettingService.getAppSettingPromise();
promises.navigationModel = BreadCrumbHelper.getNavigationPromise();
function onSuccess(responses) {
var countryId = $rootScope.locale.localeID.split(lowLine)[1]; //get country code from locale info e.g., en-IN
regionSettings.HYPHEN = hyphen;
regionSettings.localeId = $rootScope.locale.id;
regionSettings.selectedCountry = SharedService.getRegionFromCountrySet(countryId);
dcaRegionSettingsPromise.resolve(regionSettings);
}
function onError(error) {
$log.error('Unable to load the import format settings' + error);
dcaRegionSettingsPromise.reject();
}
$q.all(promises).then(onSuccess, onError);
return dcaRegionSettingsPromise.promise;
}
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报