You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
single primitive value(string or number or true&false and so on) is conform to the specifications of JSON,but now ngResource just support Array or Object response,and I know the reason when I saw the ngResource source code:
........if(action.isArray){value.length=0;forEach(data,function(item){if(typeofitem==="object"){value.push(newResource(item));}else{// Valid JSON values may be string literals, and these should not be converted// into objects. These items will not have access to the Resource prototype// methods, but unfortunately therevalue.push(item);}});}else{shallowClearAndCopy(data,value);value.$promise=promise;}
........../** * Create a shallow copy of an object and clear other fields from the destination */functionshallowClearAndCopy(src,dst){dst=dst||{};angular.forEach(dst,function(value,key){deletedst[key];});for(varkeyinsrc){if(src.hasOwnProperty(key)&&!(key.charAt(0)==='$'&&key.charAt(1)==='$')){dst[key]=src[key];}}returndst;}
Obviously it can not resolve single string or number response.
What should I do when the response is single string with ngResource?