我使用下面的代码来翻译数据表列标题,
angular.module('app')
.controller('gradeLevelCtrl', ['$scope', '$state', '$mdDialog', '$timeout', '$q', '$log', '$filter', 'DTOptionsBuilder', 'DTColumnBuilder', '$compile', '$http', '$rootScope', '$uibModal', '$translate', 'apiService', gradeLevelCtrl])
function gradeLevelCtrl($scope, $state, $mdDialog, $timeout, $q, $log, $filter, DTOptionsBuilder, DTColumnBuilder, $compile, $http, $rootScope, $uibModal, $translate, apiService) {
$scope.getDataTable = function () {
var vm = this;
vm.dtOptions = DTOptionsBuilder.fromFnPromise(function () {
var defer = $q.defer();
var bodyData = {
schoolId: 1,
yearId: 1
};
$http.post($rootScope.baseUrl + '/grade/list', bodyData)
.success(function (result) {
if (result.length < $rootScope.numberOfRecord) {
$timeout(function () {
angular.element('.dataTables_paginate').hide();
}, 200);
}
vm.grade = [];
var index = 1;
var resultData = result.data;
angular.forEach(resultData, function (value, key) {}
, vm.grade);
defer.resolve(vm.grade);
}).error(function (error) {});
vm.dtColumns = [
DTColumnBuilder.newColumn('index').withTitle($translate.instant('TABLE_LABEL_SR_NO')).withOption('searchable',false),,
DTColumnBuilder.newColumn('name').withTitle($translate.instant('TABLE_LABEL_NAME')),
DTColumnBuilder.newColumn('created_at').withTitle('Created at').withOption('searchable',false),,
DTColumnBuilder.newColumn('status').withTitle('Status').withOption('className', 'tableStatus'),
DTColumnBuilder.newColumn('operations').withTitle('Actions').withOption('orderable', false).withOption('className', 'tableActions'),
];
}
但是当语言发生变化时,它不会改变列标题的语言,对此有什么解决方法吗?