Ответ 1
Вот что я закончил делать
(function(angular) {
'use strict';
/**
* @ngdoc overview
* @name services.base64
*/
angular.module('services.base64', [])
.factory(
'Base64',
[function() {
/**
* @ngdoc service
* @name services.base64.Base64
* @description Provides encoding a string into base64, and decode base64 to a string
*/
return {
/**
* @ngdoc method
* @name encode
* @methodOf services.base64.Base64
* @param {string}
* input the string you want to encode as base64
* @returns {string} the base64 encoded string
*/
encode : function(input) {
//...
},
/**
* @ngdoc method
* @name decode
* @methodOf services.base64.Base64
* @param {string}
* input the base64 encoded string
* @returns {string} the decoded string
*/
decode : function(input) {
//...
}
};
}]);
}(angular));
Это, кажется, делает то, что я хочу... возможно, есть менее верный способ сделать, хотя?