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

Issue with priority of execution in filters #16001

Closed
wants to merge 1 commit into from

Conversation

puneeth8994
Copy link

@puneeth8994 puneeth8994 commented May 20, 2017

Need to use track by $index at the end in ng-repeat or else the filter considers $index as a value that should be filtered out. This seems to be common issue.

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
docs update

What is the current behavior? (You can also link to an open issue here)
priority of execution is important while using filters, limit, and track by $index

What is the new behavior (if this is a feature change)?

Does this PR introduce a breaking change?

Please check if the PR fulfills these requirements

Other information:

Need to use track by $index at the end in ng-repeat or else the filter considers $index as a value that should be filtered out. This seems to be common issue.
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

1 similar comment
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@puneeth8994
Copy link
Author

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

1 similar comment
@googlebot
Copy link

CLAs look good, thanks!

@Narretz
Copy link
Contributor

Narretz commented May 20, 2017

In general, the docs say that the track by expression must always go at the end, so it's definitely not optional to do it this way.

However, you get a different error message when you include the "as" part in the filter: https://docs.angularjs.org/error/$parse/syntax?p0=as&p1=is an unexpected token&p2=20&p3=$index | filter:q as results&p4=as results, see https://plnkr.co/edit/4tSsoInjMZkLJs0AUmtC?p=preview

That means if we put an explanation in the notarray error message, we are missing errors that trigger the parse syntax error.
Ideally, we would add this info to https://code.angularjs.org/snapshot/docs/error/ngRepeat/iexp, but since this is triggered before Angular parses the expression, this is difficult to do.

@Narretz
Copy link
Contributor

Narretz commented May 31, 2017

I don't feel like this makes the docs better, for the reasons pointed out above. I've opened a new issue to track a possible improvement to the ngRepeat expression parsing: #16023

@Narretz Narretz closed this May 31, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants