From a275d539f9631d6ec64d03814b3b09420e6cf1ee Mon Sep 17 00:00:00 2001 From: Renat Yakubov Date: Mon, 24 Mar 2014 22:44:08 +0300 Subject: [PATCH] fix(filter.ngdoc): Check if "input" variable is defined By default, "greeting" textfield in this example is prepopulated with "hello" text, but it's pretty easy to copy just filter code to use it in your app. If your textfield is empty while app loads, you'll get an error: "Error: [$interpolate:interr] Can't interpolate: Reverse: {{greeting|reverse}} TypeError: Cannot read property 'length' of undefined". To prevent this, we should check "input" variable, and proceed only in case it is defined. Closes #6819. --- docs/content/guide/filter.ngdoc | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/content/guide/filter.ngdoc b/docs/content/guide/filter.ngdoc index 8eedf14c81df..9ef8bcc0f99b 100644 --- a/docs/content/guide/filter.ngdoc +++ b/docs/content/guide/filter.ngdoc @@ -103,6 +103,7 @@ text upper-case. angular.module('MyReverseModule', []). filter('reverse', function() { return function(input, uppercase) { + input = input || ''; var out = ""; for (var i = 0; i < input.length; i++) { out = input.charAt(i) + out;