Issue Description: Having trouble with an AngularJS function that retrieves data from a service, concatenates certain columns, and then returns the concatenated data.
AngularJS Function:
$scope.findCompanyAddressById = function( cmpId ) {
var address = "";
$http.get(someUrl+'/company/find?id='+cmpId ).
then(function(response) {
$scope.company = response.data;
for( var i=0; i < $scope.company.locations.length; i++ ) {
address += " " + $scope.company.locations[i].street1
address += " " + $scope.company.locations[i].street2
address += " " + $scope.company.locations[i].city
address += " " + $scope.company.locations[i].state
address += " " + $scope.company.locations[i].zip
console.log( "Rendering address: " );
console.log( address ); // logs perfect data.
}
});
return address;
}
Returns undefined when calling the function like this:
$scope.concatenatedData = $scope.findCompanyAddressById( 1 );
Anyone have any suggestions on how to successfully return the concatenated data from the above function?