Thanks!. I am actually taking care of it (Sorry for posting incomplete
statement):
mcFileDownload.downloadFileFromUrl(data.mediapp.profile_image,
$rootScope).then(function(image_data) {
$scope.img = 'data:image/jpg...';
});
function downloadFileFromUrl(url) {
$http.get(url).then(function(result) {
$scope.img = 'data:image/jpg...';
});
}
On Friday, September 11, 2015 at 2:00:28 AM UTC+5:30, Todd Branchflower
wrote:
>
> Looks to me like the downloadFileFromUrl function is returning a *promise*,
> not the data that you're interested in (results.data). Remember, $http.get
> kicks off an asynchronous action - so it will return a promise that it will
> resolve to a value at some point in the future. You could do something
> like this:
>
> function downloadFileFromUrl(url) {
> $http.get(url).then(function(result) {
> $scope.img = 'data:image/jpg...';
> });
> }
>
>
>
> On Thursday, September 10, 2015 at 10:28:39 AM UTC-6, Manjunath
> Doddavenkatappa wrote:
>>
>> Hi,
>>
>> I am trying to covert data of an image to base64 encoding, and the image
>> itself is downloaded using http.get.
>>
>> For some reason, base64.encode(image_data) returns invalid data. I tried
>> all the following, but no luck:
>>
>> image_data = downloadFileFromUrl(URL); // the function is defined below
>> $scope.img = 'data:image/jpg;base64,' + $base64.encode(image_data);
>> $scope.img = 'data:image/jpg;base64,' + btoa(image_data);
>> $scope.img = 'data:image/jpg;base64,' +
>> btoa(unescape(encodeURIComponent(image_data)));
>>
>> In html, we have
>> <img ng-src="{{img}}"/>
>>
>> Download function is:
>> downloadFileFromUrl = function(url) {
>> return $http.get(url).then(function(results) {
>> return results.data;
>> }
>>
>> Any help is appreciated!
>>
>> Thank!
>> Manju
>>
>>
>>
>>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.