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

Filtering and Periods in Object Keys #6005

Closed
gabrielmiller opened this issue Jan 27, 2014 · 1 comment
Closed

Filtering and Periods in Object Keys #6005

gabrielmiller opened this issue Jan 27, 2014 · 1 comment
Assignees
Milestone

Comments

@gabrielmiller
Copy link

Hi folks,

I'm putting together a front-end for interacting with an API. The results coming from the API are namespaced based on the database tables behind the API(also being developed). During development we were naming fields like so: "table.field" to similarly match our database schema. We're doing this to avoid collisions in denormalized data. In using this naming scheme I stumbled upon what I think is a bug with ng-repeat and filtering if an object's keys have periods in them.

Here's a basic, working ng-repeat:

<input type="text" ng-model="abc.label">
<ul>
    <li ng-repeat="item in Array | filter: abc)">{{item.label}}</li>
</ul>

And here's a broken one. Let's say though that the object's key wasn't "label", but rather "meta.label":

<input type="text" ng-model="abc['meta.label']">
<ul>
    <li ng-repeat="item in Array | filter: abc)">{{item['meta.label']}}</li>
</ul>

These two examples have different behavior. It appears that the key that you're filtering on in the objects in the array cannot have a period in it. If it does have a period, the initial set will show, but as soon as the model value changes the set is truncated. Curiously even when the model's "meta.label" property is cleared, the set is still truncated.

I put together an interactive example of two ng-repeats, one over an array with objects with periods in its keys, and one over an array of objects without periods in its keys. You can see it here.

For the time being I'm going to have our API return data namespaced as "table/field", which seems to work as expected.

@ghost ghost assigned bradlygreen and IgorMinar Jan 28, 2014
IgorMinar added a commit to IgorMinar/angular.js that referenced this issue Jan 28, 2014
IgorMinar added a commit to IgorMinar/angular.js that referenced this issue Jan 28, 2014
IgorMinar added a commit to IgorMinar/angular.js that referenced this issue Jan 28, 2014
@IgorMinar
Copy link
Contributor

I sent out a PR to fix this.

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

Successfully merging a pull request may close this issue.

3 participants