Tag: angular translate

如何在angularjs中的select框选项中的ng-翻译

如何应用ng-translate来转换select框内的选项。 例如: 模板: <select class="form-control" ng-model="me.gender" ng-options="gender.name for gender in genders"> </select> 控制器: $scope.genders = [{code: "M", name:"TXT_MALE"}, {code: "F", name:"TXT_FEMALE"}] enUS.json: { "TXT_MALE": "Male", "TXT_FEMALE": "Female", } 我试图添加像filterng-options="gender.name for gender in genders | translate"但显然它是添加filter$scope.genders数组而不是单个元素 我试图写自己的filter(我是新来的) filter('translateArrayObj', ['$translate', '_', function($translate, _) { return function(arr) { var arr2 = []; angular.forEach(arr, function (value, key) { $translate(value.name).then(function(translation) […]