问题
Is it possible to render externalized strings (passed from server in my case) in the controller?
My use case: I'm using angular-toastr as an alert service, and I must pass message and title to the toastr object. The tricky part is when the strings contain scope variables, e.g: stringFromServer = "Something with {{someVariable}} went wrong".
I know in my HTTP callback about the someVariable but I want to render it to the string before passing it as a message to the alert service.
Is this possible, and what would be the best way?
回答1:
Assuming the server can render the string with a $scope.variable placeholder, $interpolate seems like what you're looking for.
Please see documentation
来源:https://stackoverflow.com/questions/32198050/angular-render-externalized-strings-containing-scope-variables-in-the-controlle