Extend the umb-radio button directive to handle localizations
This commit is contained in:
committed by
Sebastiaan Janssen
parent
2b22350d56
commit
20f886aaec
@@ -26,6 +26,7 @@
|
||||
@param {string} value Set the value of the radiobutton.
|
||||
@param {string} name Set the name of the radiobutton.
|
||||
@param {string} text Set the text for the radiobutton label.
|
||||
@param {string} labelKey Set a dictinary/localization string for the checkbox label
|
||||
@param {boolean} disabled Set the radiobutton to be disabled.
|
||||
@param {boolean} required Set the radiobutton to be required.
|
||||
@param {callback} onChange Callback when the value of the radiobutton change by interaction.
|
||||
@@ -39,15 +40,27 @@
|
||||
|
||||
var vm = this;
|
||||
|
||||
vm.$onInit = onInit;
|
||||
vm.change = change;
|
||||
|
||||
function onInit() {
|
||||
// If a labelKey is passed let's update the returned text if it's does not contain an opening square bracket [
|
||||
if (vm.labelKey) {
|
||||
localizationService.localize(vm.labelKey).then(function (data) {
|
||||
if(data.indexOf('[') === -1){
|
||||
vm.text = data;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function change() {
|
||||
if (vm.onChange) {
|
||||
$timeout(function () {
|
||||
vm.onChange({ model: vm.model, value: vm.value });
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var component = {
|
||||
@@ -60,6 +73,7 @@
|
||||
value: "@",
|
||||
name: "@",
|
||||
text: "@",
|
||||
labelKey: "@?",
|
||||
disabled: "<",
|
||||
required: "<",
|
||||
onChange: "&?"
|
||||
|
||||
Reference in New Issue
Block a user