angularjs-localizationservice
angularjs-localizationservice copied to clipboard
getLocalizedString filter returns an array!
Fixing getLocalizedString filter to select the first matched object because it returns an array!
getLocalizedString: function(KEY) { // default the result to an empty string var result = '';
// make sure the dictionary has valid data
if (localize.resourceFileLoaded) {
// use the filter service to only return those entries which match the KEY
// and only take the first result
var entry = $filter('filter')(localize.dictionary, function(element) {
return element.key === KEY;
}
)[0]; // get the first matched
// set the result
result = entry.value;
}
// return the value to the call
return result;
}