How to encode in base64 in angular js?


#1

I want to encode a data in base64 in angular js 1.3

How to do that ?

Is there any service to import ?

Thanks


#2

Javascript natively has functions to handle base64 encoding/decoding.


#3

This does not work in Angular JS 1.3

app.controller('MainCtrl', function($scope) {
var s = btoa("hello");
console.log(s); 
});

Whats the correct way to do this ?


#4

It has nothing to do with Angular, in that btoa is a native JavaScript function.

Are you testing in one of the compatible browsers? (see here)

What is logged to the console?


#5

There was a small mistake. It works perfectly.


#7

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.