Bug of ng-disabled?

2,851 views
Skip to first unread message

Freewind

unread,
Apr 27, 2012, 7:06:58 AM4/27/12
to ang...@googlegroups.com
See the demo:


When change the "title" to empty "", the update button is not disabled.

And if you input something, then press backspace to delete all non-space characters, and input some spaces, the "update" button is not disabled neither. 

Eric Jain

unread,
Apr 27, 2012, 1:17:36 PM4/27/12
to AngularJS
This works, not sure why:

http://jsfiddle.net/JXPJn/

Pawel Kozlowski

unread,
Apr 27, 2012, 1:44:59 PM4/27/12
to ang...@googlegroups.com
hi!

On Fri, Apr 27, 2012 at 7:17 PM, Eric Jain <eric...@gmail.com> wrote:

> This works, not sure why:
>
>  http://jsfiddle.net/JXPJn/

Looks like it might be a bug in angular's expresion evaluation. The
thing is that 'title.trim()' evaluates to undefined if title exuals to
''.
Have a look at this jsFiddle that exposes the pb: http://jsfiddle.net/t7DPu/24/

Cheers,
Pawel

Vojta Jína

unread,
Apr 29, 2012, 8:58:01 AM4/29/12
to ang...@googlegroups.com
Yes, there's a bug in the parser. I will send a fix.

Pawel, thanks a lot for all the answers on the mailing list. It really
helps a lot.
Do you already have a t-shirt ? You definitely deserve one...
So feel free to fill in this form
https://docs.google.com/spreadsheet/viewform?formkey=dGlWVFNocm9hWFF0Z3htVUZkNTFqOVE6MQ

V.
> --
> You received this message because you are subscribed to the Google Groups "AngularJS" group.
> To post to this group, send email to ang...@googlegroups.com.
> To unsubscribe from this group, send email to angular+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/angular?hl=en.
>

Vojta Jína

unread,
Apr 29, 2012, 9:26:49 AM4/29/12
to ang...@googlegroups.com
Ok, here is the fix https://github.com/angular/angular.js/pull/919

The original fiddle with fixed build:
http://jsfiddle.net/jcENP/2/

V.

Pawel Kozlowski

unread,
May 1, 2012, 12:27:03 PM5/1/12
to ang...@googlegroups.com
Hi!

On Sun, Apr 29, 2012 at 2:58 PM, Vojta Jína <vojta...@gmail.com> wrote:

> Pawel, thanks a lot for all the answers on the mailing list. It really
> helps a lot.
> Do you already have a t-shirt ? You definitely deserve one...

Cool, the T-shirt will come handy when doing a talk about angular.js
with the focus on e2e testing (at my workplace so won't be able to
share...).
Glad that my posts on this mailing list were helpful - for me it was
just a way of exploring angular. If - at the same time - it was
saving others some time then this is even better.
Done, thnx!

And pleeeeasssee, continue work on this amazing piece of client-side
technology, it is really great so see / use some truly innovative
approach.

Cheers,
Pawel

Vojta Jína

unread,
Jun 16, 2012, 9:53:28 PM6/16/12
to ang...@googlegroups.com
1/ ng-model trims values by default.
2/ you can do ng-disabled="!someString.trim().length" to get true for both "null" and 0
3/ it works for me, I'm not getting null value

Send a fiddle.

V.

On Fri, Jun 15, 2012 at 5:07 AM, shotleybuilder <drjason...@gmail.com> wrote:
Hi

Running 1.0rc10.
The only way I could get the behaviour is like this:

ng-disabled="someString.trim().length==null || someString.trim().length==0"

The behaviour I experience using Mozilla with just  ng-disabled="someString.trim().length==0".
1. Page refreshed, empty input. Length = 0.
2. Add some text to input.  Length > 0.
3. Backspace / delete text.  Length null.

But the jsFiddle works in my browser and I reckon I've copied it straight.
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/pwn0X8chEd0J.
Reply all
Reply to author
Forward
0 new messages