我正在使用wrapbootstrap购买的管理信息中心管理员构建应用。
它带有一个加载json文件进行翻译的模块。
我通过html这样访问这个参数
{{ 'parameters.items.ITEM1' | translate }}
我想知道我是否可以从控制器访问这些参数。 这个想法是显示用用户语言编写的javascript警报。
EDIT companies.detail.html
<script type="text/ng-template" id="/confirm.companies.delete.html">
<div class="modal-header">
<button type="button" data-dismiss="modal" aria-hidden="true" class="close">×</button>
<h4 id="myModalLabel" class="modal-title">{{ 'general.modal.title.WARNING' | translate }}</h4>
</div>
<div class="modal-body" style="white-space: pre-wrap;"> {{ 'companies.modal.DELETE' | translate }} </div>
<div class="modal-footer">
<button ng-click="ok()" class="btn btn-primary">{{ 'general.modal.button.OK' | translate}}</button>
<button ng-click="cancel()" class="btn btn-warning">{{ 'general.modal.button.CANCEL' | translate}}</button>
</div>
</script>
EDIT companies_detail.js
(function() {
'use strict';
angular
.module('appname')
.controller('companyDetailCtrl', companyDetailCtrl);
companyDetailCtrl.$inject = ['$scope','Data','$log', '$uibModal', '$location', '$state', 'SweetAlert','$rootScope', '$translate'];
function companyDetailCtrl($scope, Data, $log, $uibModal, $location, $state, SweetAlert,$rootScope, $translate){
Data.get('companies/'+$scope.company_id).then(function(data){
$scope.companyDetail = data[0];
});
$scope.openAlert = function(){
//HERE I NEED TO ACCESS THAT JSON PARAMETERS TO FORMAT SWEETALERT
SweetAlert.swal({
title: 'Are you sure?',
text: 'Your will not be able to recover this imaginary file!',
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#DD6B55',
confirmButtonText: 'Yes, delete it!',
cancelButtonText: 'No, cancel plx!',
closeOnConfirm: false,
closeOnCancel: false
}, function(isConfirm){
if (isConfirm) {
SweetAlert.swal('Deleted!', 'Your imaginary file has been deleted.', 'success');
} else {
SweetAlert.swal('Cancelled', 'Your imaginary file is safe :)', 'error');
}
});
};
$scope.updateCompany = function(company_id){
Data.put('companies/'+company_id, $scope.companyDetail).then(function(data){
if(data=true){
$state.reload();
history.back();
} else {
$log.log('companyDetailCtrl > Error > no se pudo actualizar la empresa.');
};
});
};
$scope.deleteCompany = function(company_id){
//$log.log(company_id);
Data.delete('companies/'+company_id, $scope.companyDetail).then(function(data){
if(data=true){
$state.reload();
history.back();
} else {
$log.log('companyDetailCtrl > Error > no se pudo eliminar la empresa.');
};
});
};
$scope.historyBack = function(){
$state.reload();
history.back();
};
};
})();
编辑en_US.json
{
"dashboard": {
"WELCOME": "Welcome to {{appName}}"
},
"topbar": {
"search": {
"PLACEHOLDER": "Type and hit enter.."
}
},
"sidebar": {
"WELCOME": "Welcome",
"heading": {
"HEADER": "Main Navigation"
},
"nav": {
"SINGLEVIEW": "Single View",
"DASHBOARD": "Dashboard",
"COMPANIES": "Companies",
"menu": {
"MENU": "Menu",
"SUBMENU": "Sub Menu"
}
}
},
"companies": {
"WELCOME": "List of the companies associated to the system",
"grid": {
"ID":"uID",
"NAME":"Name",
"DOCUMENT":"Document",
"DOCUMENT_TYPE":"Document type",
"ADDRESS":"Address",
"PHONE1":"Phone",
"PHONE2":"Alt. Phone",
"WEBSITE":"Website",
"EMAIL":"Email",
"LOGO":"Logo",
"ACTIONS":"Actions"
},
"buttons":{
"NEW":"Add company"
},
"modal":{
"ADD":"You are about to add a new company. \n\r Are you sure?",
"DELETE":"You are about to delete the company. \n\r This process cannot be undone. \n\r Are you sure?"
},
"SEARCH":"Filter companies"
},
"forms": {
"validate":{
"REQUIRED":"Required field",
"EMAIL":"Invalid email format"
},
"buttons":{
"BACK":"Back",
"SAVE":"Save",
"DELETE":"Delete",
"EDIT":"Edit"
}
},
"general": {
"modal":{
"title":{
"WARNING":"WARNING!",
"ERROR":"ERROR!"
},
"button":{
"OK":"Accept",
"CANCEL":"Cancel"
}
}
}
}
我正试图在$ scope.openAlert
中达到general.modal.title.WARNING感谢您的帮助。