我现在有一个问题,我正在使用angular js来获取和显示数据。以下是代码
var angularDynamicsCRM = angular.module('angularDynamicsCRM', ['ngResource']);
/// define the DynamicsCRMService factory
angularDynamicsCRM.factory('DynamicsCRMService', function ($resource) {
var oDataUrl = Xrm.Page.context.getClientUrl() + '/api/data/v9.1/';
var defaultParams = {};
/// describe our API actions
var actions = {
lookup: {
method: 'GET',
url: oDataUrl + ':Entityname?$select=:SelectQuery&$filter=:FilterQuery :RecordGuid',
headers: {
"Accept": "application/json",
"OData-MaxVersion": "4.0",
"OData-Version": "4.0",
"Prefer": "odata.include-annotations=\"*\""
}
}
};
/// create the service
return $resource(oDataUrl, defaultParams, actions)
});
我的控制器代码如下
DynamicsCRMService.lookup(
{
Entityname: SelectedRecord[n].lti_entityname,
RecordGuid: SelectedRecordID,
SelectQuery: SelectedRecord[n].lti_selectquery,
FilterQuery: SelectedRecord[n].lti_filterquery
},
function (response) {
setdata.push(response.value);
});
问题是每次我在控制器中使用以上命令时,我总是最终会以不同的顺序获取数据(异步) 任何人都可以建议一种方法,让我按照同步而不是异步的特定顺序获取数据