Broken Filter on Search Object

144 views
Skip to first unread message

Pepper Lebeck-Jobe

unread,
May 26, 2012, 10:29:03 PM5/26/12
to ang...@googlegroups.com
When you are using a filter on a template object and one of the properties of the template object is bound to a select box which has a "None" option which sets the value back to the empty string.  The filter matches Nothing instead of Everything.  To demonstrate:


If you select "red" from the "Broken Filter Select" dropdown, it filters correctly, but when you switch back to "None" it shows no results.

However when you select "red" from the "Working Filter Select" dropdown, it filters correctly, and when you switch back to "None" it shows all results.

Why is that?  Is it a bug?

Thanks,
Pepper

Pawel Kozlowski

unread,
May 27, 2012, 3:40:10 AM5/27/12
to ang...@googlegroups.com
Hi Pepper!

On Sun, May 27, 2012 at 4:29 AM, Pepper Lebeck-Jobe <elj...@gmail.com> wrote:
> When you are using a filter on a template object and one of the properties
> of the template object is bound to a select box which has a "None" option
> which sets the value back to the empty string.  The filter matches Nothing
> instead of Everything.  To demonstrate:
>
> http://jsfiddle.net/eljobe/H5yuW/

I would consider this a bug... I've slightly modified the jsFiddle to
see what is going on:
http://jsfiddle.net/pkozlowski_opensource/H5yuW/10/

As you can see from the console output the difference is that:
1) at the begining the search.name is initailized to an empty string
2) selecting None binds null to the search.name

A work-around I could think of would consist of watching search.name,
like this: http://jsfiddle.net/pkozlowski_opensource/H5yuW/11/
There are probably other approaches (like having colors holding not
only labels but objects with lable=>value), but once again I find this
behaviour puzzling so this should either be considered as a bug or
what do we miss here is an ability to specify the model value for
<option>.

Cheers,
Pawel

Pepper Lebeck-Jobe

unread,
May 27, 2012, 11:17:52 AM5/27/12
to ang...@googlegroups.com
Pawel,

Thanks for the excellent explanation and work-around. Should I file an official bug somewhere about the broken behavior?

Thanks,
Pepper


--
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.


Dan Doyon

unread,
May 27, 2012, 1:44:24 PM5/27/12
to ang...@googlegroups.com
Pepper, 

Go to the github issues https://github.com/angular/angular.js/issues?utf8=%E2%9C%93 and file there. I took a quick look and don't think I saw anything like this

-dan

philipp...@googlemail.com

unread,
Aug 10, 2012, 2:32:37 PM8/10/12
to ang...@googlegroups.com
Hi,

I'm struggling with the same problem.
Good thing there is such a good mailing list!

@Pawel: thank you for the workaround.
@Pepper: did you open an issue at github?


Philipp
Reply all
Reply to author
Forward
0 new messages