मुझे एंगुलरजेएस के $ http के साथ एक अजीब व्यवहार हो रहा है और वास्तव में यह समझ में नहीं आता कि ट्रांसफ्रेंस कैसे काम करता है (दस्तावेज़ इस पर थोड़ा हल्का है)।
WebAssets.get = function() {
return $http.get('/api/webassets/list', {
transformResponse: [function (data, headersGetter) {
// not sure what to do here?!
return data;
}].concat($http.defaults.transformResponse) // presume this isn't needed, added for clarity
}).then(function (response) {
return new WebAssets(response.data);
});
};
एपीआई ऑब्जेक्ट की श्रृंखला रिटर्न:
[{"webasset_name": "...", "application_id": "...", "etc": "..."}, ... ]
लेकिन जब transformResponse किया है यह बुराई व्यावसायिक डेटा एक अनुक्रमित वस्तु में तब्दील हो गया है:
{"0":{"webasset_name":"...","application_id":"...", "etc": "..."}, "1":....}
मैं रखना चाहते हैं मूल डेटा संरचना (वस्तुओं की एक सरणी)।
आप यहाँ देखने के लिए चाहते हो सकता है: http://stackoverflow.com/questions/17134401/angular-extending-resource-subobject-with-custom-methods – AlwaysALearner
वे $ संसाधन का उपयोग कर रहे हैं, मैं $ http –