|
54 | 54 | * <span ng-non-bindable>`{{personCount}}`</span>. The closed braces `{}` is a placeholder
|
55 | 55 | * for <span ng-non-bindable>{{numberExpression}}</span>.
|
56 | 56 | *
|
| 57 | + * If no rule is defined for a category, then an empty string is displayed and a warning is generated. |
| 58 | + * Note that some locales define more categories than `one` and `other`. For example, fr-fr defines `few` and `many`. |
| 59 | + * |
57 | 60 | * # Configuring ngPluralize with offset
|
58 | 61 | * The `offset` attribute allows further customization of pluralized text, which can result in
|
59 | 62 | * a better user experience. For example, instead of the message "4 people are viewing this document",
|
|
172 | 175 | </file>
|
173 | 176 | </example>
|
174 | 177 | */
|
175 |
| -var ngPluralizeDirective = ['$locale', '$interpolate', function($locale, $interpolate) { |
| 178 | +var ngPluralizeDirective = ['$locale', '$interpolate', '$log', function($locale, $interpolate, $log) { |
176 | 179 | var BRACE = /{}/g,
|
177 | 180 | IS_WHEN = /^when(Minus)?(.+)$/;
|
178 | 181 |
|
@@ -216,7 +219,13 @@ var ngPluralizeDirective = ['$locale', '$interpolate', function($locale, $interp
|
216 | 219 | // In JS `NaN !== NaN`, so we have to exlicitly check.
|
217 | 220 | if ((count !== lastCount) && !(countIsNaN && isNaN(lastCount))) {
|
218 | 221 | watchRemover();
|
219 |
| - watchRemover = scope.$watch(whensExpFns[count], updateElementText); |
| 222 | + var whenExpFn = whensExpFns[count]; |
| 223 | + if (angular.isUndefined(whenExpFn)) { |
| 224 | + $log.debug("ngPluralize: no rule defined for '" + count + "' in " + whenExp); |
| 225 | + } |
| 226 | + else { |
| 227 | + watchRemover = scope.$watch(whenExpFn, updateElementText); |
| 228 | + } |
220 | 229 | lastCount = count;
|
221 | 230 | }
|
222 | 231 | });
|
|
0 commit comments