我有一个div
它的内容是通过 Web 服务接收的动态文本。我希望将此内容从西类牙语(原始语言)翻译成英语。我该怎么做?我见过一些翻译单词的库,但这种情况发生了,还添加了翻译,在我的例子中,它们是小的动态文本。
<div>
esto es un texto dinámico
</div
结果应该是
<div>
this is a dynamic text
</div
这是我的代码:
<div ng-app="testApp" ng-controller="testController as $ctrl">
<div>
esto es un texto dinámico
</div>
</div>
var app = angular.module('testApp', []);
app.controller('testController', ['$scope', '$http', function($scope, $http) {
}]);
最佳答案
这是使用 Angular 中的Interpolation
解决的。你应该熟悉它。 http://excellencenodejsblog.com/angularjs-compile-parse-interpolate/
Controller 端:
//...
$scope.myContent = getMyContent()
模板面:
<div>{{myContent}}</div>
getMyContent()
方法应返回您想要的语言的文本。
在这里摆弄:
关于javascript - 如何在 angular.js 中将 div 的所有内容从西类牙语翻译成英语?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48646209/