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

ng-hide evaluates empty strings as truthy #5691

Closed
fmalk opened this issue Jan 8, 2014 · 1 comment
Closed

ng-hide evaluates empty strings as truthy #5691

fmalk opened this issue Jan 8, 2014 · 1 comment
Assignees

Comments

@fmalk
Copy link

fmalk commented Jan 8, 2014

Version 1.2.0 introduced a bug in my UI where ng-hide treats a promise evaluated as an empty string as truthy. Up to version 1.0.8, ng-hide would evaluate an empty string as falsy, following Javascript logic:

"" == true
false

"" == false
true

This is a standard case IMO: a controller calls a service for logged user, server returns 204 code (no content), $http receives an empty string as data, calls promise resolve() with an empty string. The directive <div ng-hide="variable"> should treat variable with empty string as falsy.

Related issues: #3969, #4005

@ghost ghost assigned tbosch Jan 9, 2014
@tbosch
Copy link
Contributor

tbosch commented Jan 9, 2014

Hi,
Angular 1.2.0 deprecated and deactivated promise unwrapping by default. If you still need it you can turn it on again using $parseProvider.unwrapPromises(). However, in Angular 1.3.0 we will no more support it.

So you need to unwrap the promise in your controller...

Closing this. Please comment if I understood you wrong.

@tbosch tbosch closed this as completed Jan 9, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants