DJ22T
DJ22T

Reputation: 1640

Angular SweetAlert with directives and translate

im currently using Angular implementation of the

Sweet alert

I want to pass to the title an Angular directive with translate

This is the variable I'm passing as title

{{ 'register.confirmation_modal.SUPERIOR_MESSAGE' | translate }}

And using Angular Compile Service

var translate_title = "<span>{{ 'sa.title' | translate }}</span>";
var compiled_title = $compile(translate_title)($scope);

and using html: true, in Sweet alert options

But i'm getting an object and it's being printed like the follow image

enter image description here

I tried using .innerHTML but it removes the Tags and gets the literal string with the curly braces {{ }}

JSON.stringify didn't worked either.

Any advice?

Upvotes: 0

Views: 1494

Answers (1)

DJ22T
DJ22T

Reputation: 1640

Credits to @Claies for pointing me to the solution

Instead of using $compile I solved my issue using the Filter translate from Angular translate

This did the trick:

var n = $filter('translate')('sa.title');

Regards.

Upvotes: 1

Related Questions