null and other falsy values should not be rendered in the view

Closes #242
This commit is contained in:
Igor Minar 2011-01-20 12:55:03 -08:00
parent 17ee0f031a
commit 4a569560d8
2 changed files with 7 additions and 1 deletions

View file

@ -210,7 +210,7 @@ angularDirective("ng:bind", function(expression, element){
element.html('');
element.append(value);
} else {
element.text(value === _undefined ? '' : value);
element.text(value == _undefined ? '' : value);
}
}
}, element);

View file

@ -80,6 +80,12 @@ describe("directive", function(){
expect(sortedHtml(scope.$element)).toEqual('<div>before<div class="filter" ng:bind="0|myFilter">HELLO</div>after</div>');
});
it('should suppress rendering of falsy values', function(){
var scope = compile('<div>{{ null }}{{ undefined }}{{ "" }}-{{ 0 }}{{ false }}</div>');
expect(scope.$element.text()).toEqual('-0false');
});
});
describe('ng:bind-template', function(){