Skip to content

Commit

Permalink
Extend the umb-radio button directive to handle localizations
Browse files Browse the repository at this point in the history
  • Loading branch information
BatJan authored and nul800sebastiaan committed Oct 24, 2019
1 parent 2b22350 commit 20f886a
Showing 1 changed file with 15 additions and 1 deletion.
Expand Up @@ -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.
Expand All @@ -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 = {
Expand All @@ -60,6 +73,7 @@
value: "@",
name: "@",
text: "@",
labelKey: "@?",
disabled: "<",
required: "<",
onChange: "&?"
Expand Down

0 comments on commit 20f886a

Please sign in to comment.