Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix(filter.ngdoc): Check if "input" variable is defined
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
renatus authored and tbosch committed Mar 24, 2014
1 parent b472d02 commit 4a6d4de
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions docs/content/guide/filter.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4a6d4de

Please sign in to comment.