Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Using ng-repeat track by fails with No "getter for $index" when using transformer #1307

Open
lasse-damgaard opened this issue Aug 4, 2014 · 12 comments
Milestone

Comments

@lasse-damgaard
Copy link

Using track by $index fails with a "no getter" exception when using the angular transformer.
Issue 1023 seems related.

No getter for '$index'.

STACKTRACE:
Error
    at dart.wrapException (http://localhost:8080/main.dart.js:2506:15)
    at StaticClosureMap.lookupGetter$1 (http://localhost:8080/main.dart.js:10686:17)
    at DynamicParserBackend.newAccessScope$1 (http://localhost:8080/main.dart.js:8926:21)
    at DynamicParserImpl.parseAccessOrCallScope$0 (http://localhost:8080/main.dart.js:9280:29)
    at DynamicParserImpl.parsePrimary$0 (http://localhost:8080/main.dart.js:9256:21)
    at DynamicParserImpl.parseAccessOrCallMember$0 (http://localhost:8080/main.dart.js:9213:21)
    at DynamicParserImpl.parsePrefix$0 (http://localhost:8080/main.dart.js:9209:21)
    at DynamicParserImpl.parseMultiplicative$0 (http://localhost:8080/main.dart.js:9188:21)
    at DynamicParserImpl.parseAdditive$0 (http://localhost:8080/main.dart.js:9177:21)
    at DynamicParserImpl.parseRelational$0 (http://localhost:8080/main.dart.js:9162:21) 

index.html

<!DOCTYPE html>
<html ng-app>
<body>
<span ng-repeat="item in [1,1,1] track by $index">{{item}}</span>
<script type="application/dart" src="main.dart"></script>
<script type="text/javascript" src="packages/browser/dart.js"></script>
</body>
</html>

main.dart

import 'package:angular/angular.dart';
import 'package:angular/application_factory.dart';

void main() { applicationFactory()
        .run();
}

pubspec.yaml

name: test
version: 0.0.1
dependencies:
  angular: 0.13.0
  browser: any
transformers:
  - angular:
      html_files:
        - web/index.html
@vicb vicb added the type: bug label Aug 5, 2014
@vicb
Copy link
Contributor

vicb commented Aug 5, 2014

You're right, this is related to #1023.

We need to evaluate the expressions in both case meaning that the transformers should extract the expressions from the source.

Fixing this issue might involve using the parser in the expression extractor as a regexp might not be enough (related to #1050).

As a workaround, you can add the expression in the expressions config on your enclosing @Controller or @Component

@tkrotoff
Copy link

tkrotoff commented Sep 2, 2014

@vicb expressions? I guess you mean exportExpressions

@vicb
Copy link
Contributor

vicb commented Sep 4, 2014

@tkrotoff youe are right, you should use exportExpressions. sorry for the confusion.

@rkirov rkirov closed this as completed Oct 9, 2014
@lassedamgaard
Copy link

@rkirov Has this been fixed?

@rkirov
Copy link
Contributor

rkirov commented Oct 10, 2014

AFAIKT, you just need to use exportExpressions.

@lassedamgaard
Copy link

Right, that's a workaround for the issue as @vicb mentions. But IMHO it doesn't really make sense that every user should have to do this for every project to use something that is built into the framework and should work out of the box.

@naomiblack
Copy link
Contributor

Hi Lasse,
You're right -- this is definitely an area that could be improved in Angular. We'll keep this in mind as part of our next-gen work. Hopefully the workaround will get you unstuck for the immediate future.

@lassedamgaard
Copy link

Guys, please reopen this. From the point of view of a library user it's a bug by any reasonable standard.

@rkirov
Copy link
Contributor

rkirov commented Oct 14, 2014

Sorry, for not being clear. Closing the issue is not saying this is not a bug, but rather indicating that we are not going to work on it in the near future. PRs are always welcome.

@tkrotoff
Copy link

@rkirov

Closing the issue is not saying this is not a bug, but rather indicating that we are not going to work on it in the near future

You have GitHub labels for that... If you acknowledge the bug exists and is valid then the GitHub issue should not be closed. Check other popular GitHub projects and you will see that this is how people work (examples, sorted by date: 1, 2, 3... see how old these issues are and the number of comments).

PRs are always welcome

If you close the issue, you can be sure that no PR will land => it's like the issue does not even exist.

@naomiblack naomiblack added this to the post v1.0 milestone Oct 14, 2014
@naomiblack
Copy link
Contributor

OK -- reopening, but tagged as post-v1.0 Milestone. Thanks for the discussion.

@naomiblack naomiblack reopened this Oct 14, 2014
@rkirov
Copy link
Contributor

rkirov commented Oct 14, 2014

@tkrotoff Fair enough, issue is reopened to improve visibility for potential contributors.

Cross-referencing here the Google groups discussion - https://groups.google.com/forum/#!topic/angular-dart/cbXcHwBcuoM concerning the bigger picture with Angular.Dart v1.0 and Angular v2.0.

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

No branches or pull requests

6 participants