How to encode in base64 in angular js?

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

How to do that ?

Is there any service to import ?


Javascript natively has functions to handle base64 encoding/decoding.

This does not work in Angular JS 1.3

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

Whats the correct way to do this ?

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?

There was a small mistake. It works perfectly.

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