服务返回data
(原始的 $http 响应)而不是result
(我想传回控制器的处理后的版本),为什么里面的代码promise
被忽略了?
///in controller
Romanize.get($scope.currentMaterial).then(function(d){
$scope.romanized = d;
});
//service
app.factory('Romanize', ['$http', 'Position', function($http, Position){
return{
get: function(query){
var url= Position.sections[Position.sectionNumber].romanizeService + "?korean=" + query;
var promise = $http.get(url).success(function(data) {
var parts = $(data).find("span");
var array = [];
for (var x = 0; x<parts.length; x++){
array.push(parts[x].title);
}
var result = array.join("");
return result;
});
return promise;
}
};
}]);