Encode or decode strings using angularJS

There are certain ways to encode or decode string in angulars. In this code snippet we will take a look a very simplest way:

Lets see how we can do the same in JQuery


$.base64.encode("Demo test text"); 



Try this when using IE10+

var decod = window.atob(str);   
var encode = window.btoa(str); 

Here is the way using AngularJS

var app = angular.module("encodeDecode", []);  
app.controller("encodeDecodeCtrl", ($scope, str) => {  
    $scope.encode = btoa(str);  
    $scope.decode = atob(str);  

Leave A Reply