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

ng-repeat won't work if my object keys starting with "$" and there is no error messages #11379

Closed
puncha opened this issue Mar 20, 2015 · 3 comments

Comments

@puncha
Copy link

puncha commented Mar 20, 2015

<div ng-app='app'>
  <h1 ng-repeat='(key,val) in {"SimpleKey":"This works fine"}'>{{key}}:{{val}}</h1>
  <h1 ng-repeat='(key,val) in {"Key/$/FOO":"This works fine"}'>{{key}}:{{val}}</h1>
  <h1 ng-repeat='(key,val) in {"$/FOO":"This does NOT work fine!"}'>{{key}}:{{val}}</h1>
</div>

The related codes in angularjs:

if (collection.hasOwnProperty(key) && key.charAt(0) != '$') {
    collectionKeys.push(key); 
}

IMO, this is a limitation or a bug in AngularJs side. It is very inconvenient because each time to use ng-repeat to iterate over object keys, we need to ensure each key not start with $, or it won't work and there is no error messages.

Also there is a post on stackoverflow:
http://stackoverflow.com/questions/29141277/angularjs-ng-repeat-doesnt-work-if-the-key-starts-with

@wesleycho
Copy link
Contributor

The $ prefix is considered semi-private to Angular (generally signifying API) - this is pretty well known, and I do not believe this should be modified in Angular.

@miraage
Copy link

miraage commented Mar 20, 2015

$ and $$ are reserved AngularJS internal prefixes. You should not use them.

@Narretz Narretz added this to the Backlog milestone Apr 28, 2015
Narretz added a commit to Narretz/angular.js that referenced this issue Feb 8, 2016
Narretz added a commit to Narretz/angular.js that referenced this issue Feb 8, 2016
@Narretz
Copy link
Contributor

Narretz commented Feb 8, 2016

Dupe of #6266

@Narretz Narretz closed this as completed Feb 8, 2016
Narretz added a commit to Narretz/angular.js that referenced this issue Feb 9, 2016
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

4 participants