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

ng-show doesn't display element when element has "filter" applied to an array. #15804

Closed
joels341 opened this issue Mar 13, 2017 · 1 comment
Closed

Comments

@joels341
Copy link

Note: for support questions, please use one of these channels: https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#question. This repository's issues are reserved for feature requests and bug reports.

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

In 1.6.2, ng-show is ignored when the same element has an ng-bind that contains a filter on an array.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (template: http://plnkr.co/edit/tpl:yBpEi4).

https://jsfiddle.net/r8o95zcf/

What is the expected behavior?

When user types a search query in the box, the form should be come "dirty" and the span element with ng-show should display the found array element due to the filter applied. As it currently stands, the span tag remains hidden even though the filter is working correctly.

That is to say, placing a filter inside an ng-bind with an array should not affect the behavior of ng-show.

What is the motivation / use case for changing the behavior?

Not using ng-show means that the initially all elements of the array will be displayed. In some use cases, it makes sense to hide the available array elements until the user has attempted to interact with the form (making it dirty).

Which versions of AngularJS, and which browser / OS are affected by this issue? Did this work in previous versions of AngularJS? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.

Latest version of Chrome and Firefox 51.0.1. Tested with angular 1.6.2 and https://code.angularjs.org/snapshot/angular.js behavior is the same.

Other information (e.g. stacktraces, related issues, suggestions how to fix)

Don't know.

@Narretz
Copy link
Contributor

Narretz commented Mar 13, 2017

That's because ngBind cannot handle the results of filtered expressions. That causes an infinite digest error. See issue #9717. You can see in the console that this error is also thrown for the first ng-bind (without ng-show). As a workaround, you can use interpolation instead of ngBind: https://jsfiddle.net/527nLcrj/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants