How can I get data in a specific order in angular js

165 Views Asked by At

I have a problem current in which i am using angular js to fetch and display data. The following is the code

    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)

});

my controller code is as follows

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);                  
    });                         

the problem is that every time i use the above in my controller i always end up getting data in a different order(async) Can anyone please suggest a way in which i can get the data as per a specific order that is sync and not async

0

There are 0 best solutions below