javascript - How to return transformed data from a $http.json request in angular? -


how can return apidata.map , not default success apidata using $http.jsonp?

langdataservice constructor:

 languages.langdataservice = function($http, $q) {    this.langdefer = $q.defer();    this.isdataready = this.langdefer.promise;  };   languages.langdataservice.prototype.getapi = function() {     return this.isdataready = this.http_.jsonp(url, {         params: {}       })       .success(function(apidata) {         return apidata.map(function(item){               return item + 1; //just example.          });       }); }; 

a ctrl using landdataservice:

languages.languagectrl = function(langdataservice) {    languages.langdataservice.isdataready.then(function(data){        console.log('whooo im transformed dataset', data);    }); } 

use then instead of success in getapi function.


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -