aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/directive/ngPluralize.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/ng/directive/ngPluralize.js')
-rw-r--r--src/ng/directive/ngPluralize.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/ng/directive/ngPluralize.js b/src/ng/directive/ngPluralize.js
index 6ab1e182..1cefc476 100644
--- a/src/ng/directive/ngPluralize.js
+++ b/src/ng/directive/ngPluralize.js
@@ -174,13 +174,20 @@ var ngPluralizeDirective = ['$locale', '$interpolate', function($locale, $interp
restrict: 'EA',
link: function(scope, element, attr) {
var numberExp = attr.count,
- whenExp = element.attr(attr.$attr.when), // this is because we have {{}} in attrs
+ whenExp = attr.$attr.when && element.attr(attr.$attr.when), // we have {{}} in attrs
offset = attr.offset || 0,
- whens = scope.$eval(whenExp),
+ whens = scope.$eval(whenExp) || {},
whensExpFns = {},
startSymbol = $interpolate.startSymbol(),
- endSymbol = $interpolate.endSymbol();
+ endSymbol = $interpolate.endSymbol(),
+ isWhen = /^when(Minus)?(.+)$/;
+ forEach(attr, function(expression, attributeName) {
+ if (isWhen.test(attributeName)) {
+ whens[lowercase(attributeName.replace('when', '').replace('Minus', '-'))] =
+ element.attr(attr.$attr[attributeName]);
+ }
+ });
forEach(whens, function(expression, key) {
whensExpFns[key] =
$interpolate(expression.replace(BRACE, startSymbol + numberExp + '-' +