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

ng-repeat fails to show items when filter text is null (1.3.15) #11573

Closed
@RickStrahl

Description

@RickStrahl

Upgraded to 1.3.15 today in one of my apps and found that an ng-repeat option list with a filter no longer displayed any items. It appears the problem is due to the fact the initial string filter value is null - if I change the initial value to an empty string it works.

// intial view model value that doesn't work
vm.searchText = null;
vm.resourceList = [ 
   { ResourceId: "Add", Style=null },
   { ResourceId: "Add_Title", Style="margin-left: 10px" },
   ...
];

Then in the HTML to bind:

<option ng-repeat="resource in view.resourceList | filter:view.searchText"
        value="{{resource.ResourceId}}"
        style="{{resource.Style}}">
    {{resource.ResourceId}}
</option>

If the intial value of searchText is null the list will not display any items. If the initial value is an empty string (""), however it works fine. This is a breaking change from 1.3.14 where this worked. If by design this should probably go into the breaking change list.

However I think null should be treated like an empty string for search filters I believe so I'd call this a bug...

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions