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.

ngRepeat: property names starting with "$" will not be rendered #6266

Closed
@mgmeyers

Description

@mgmeyers

When using ngRepeat to iterate over an object, it will not output any key-value pair where the key starts with a dollar sign ($).

Here is a demo:
http://jsfiddle.net/takvg/4/

And, the actual code in question can be found here: https://github.com/angular/angular.js/blob/master/src/ng/directive/ngRepeat.js#L284

if (isArrayLike(collection)) {
  collectionKeys = collection;
  trackByIdFn = trackByIdExpFn || trackByIdArrayFn;
} else {
  trackByIdFn = trackByIdExpFn || trackByIdObjFn;
  // if object, extract keys, sort them and use to determine order of iteration over obj props
  collectionKeys = [];
  for (key in collection) {
    if (collection.hasOwnProperty(key) && key.charAt(0) != '$') {
      collectionKeys.push(key);
    }
  }
  collectionKeys.sort();
}

Specifically:

key.charAt(0) != '$'

I'm assuming this is to prevent angular's internal properties from being iterated over by ngRepeat. I would suggest removing this limitation, but I don't know enough about the internals or the reasoning behind this to know what effect that might have.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions