angularjs-localizationservice icon indicating copy to clipboard operation
angularjs-localizationservice copied to clipboard

getLocalizedString filter returns an array!

Open abods opened this issue 9 years ago • 0 comments

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;

}

abods avatar Sep 20 '15 21:09 abods