Quantcast
Channel: Gaurav-Arora.com » Code-Snippets
Viewing all articles
Browse latest Browse all 8

Encode or decode strings using angularJS

$
0
0

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

Encoding

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

Decoding

$.base64.decode("aghTcycpcyBhIHRlc3Q=");

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);  
}); 

The post Encode or decode strings using angularJS appeared first on Gaurav-Arora.com.


Viewing all articles
Browse latest Browse all 8

Trending Articles