My goal is to retrieve a string from a template that I can later edit using Textangular or save in a database. This template comes from the server and is stored in the database.
TemplateMailService.get($scope.type, function (data, status) {
$scope.template = data.template;
$timeout(function () {
data.template.content = $compile(data.template.content)($scope);
$log.debug('$scope.mail.content : ', $scope.mail.content);
$log.debug('data.template.content : ', angular.element(data.template.content));
var string = '';
string += data.template.content[0].innerHTML;
console.log(string);
$scope.mail.content = string;
}, 0);
})
I aim to save the compiled template with all the ng-xx attributes and {{ variables }} applied as a string so that I can edit it in textangular.
I understand that this could be achieved by using a directive, but I'm not sure how to return the compiled template in a string form.
What am I overlooking here?
Thanks.