After taking inspiration from this GitHub repository, I decided to add some TypeScript flavor to it:
angular
.module('myApp', ['base64'])
.controller('myController', [
'$base64', '$scope',
function($base64: any, $scope : ng.IScope) {
$scope.encoded = $base64.encode('a string');
$scope.decoded = $base64.decode('YSBzdHJpbmc=');
}]);
In this code snippet, I've simply specified the type of $base64 as "any", allowing for using regular JavaScript without TypeScript errors. While you won't have IntelliSense or type checking with this approach, in certain scenarios it may not be necessary. However, if you prefer defining your own interface for better typing, you can do so like this:
interface Base64Encode {
encode: (source: string) => string;
decode: (encoded: string) => string;
}