javascript - "sort not a function" error in angularjs only in google chrome -


i ran problem , unable figure out why , couldn't find explanation on google. have $http.get method retrieve data url, on success sorting response. when run page on google chrome, error "typeerror: response.sort not function"

var orderofgroups = ["alpha", "beta", "gamma", "delta"];  $http.get(url) .success( function (response, status, headers, config) {     response.sort( function(a, b) {         var aname = orderofgroups.indexof(a.team);         var bname = orderofgroups.indexof(b.team);          return bname-aname;     }); }); 

i getting error @ "response.sort" line. happening in google chrome, tested in firefox , ie10, , working fine on these browsers. json data receiving (response) has following format

[     {         team: "gamma",         value: "p"     },     {         team: "alpha",         value: "q"     },     ...... ] 

could please tell me how can resolve this?

your response not array. object property contains array (e.g. response.data) or string version of array , need use json.parse , convert string array.

anyway, sort on array's prototype - means arrays have property on them - not related angularjs or google chrome.


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -