question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Angular 2 *ngFor only supports to add 10 elements at a time in inline template

See original GitHub issue

**I’m submitting a bug.

[x ] bug report
[ ] feature request
[ ] support request

Current behavior

I wanted to repeat particular element several amount of time, so I’m using *ngFor directive with hard-coded array like [1,2,3,4,5,6,7,8,9,10] and that got worked awesome. I achieved what I wanted to do.

Code

@Component({
  selector: 'my-app',
  template: `<h1>My First Angular App</h1>
      <div *ngFor="let item of [1,2,3,4,5,6,7,8,9,10]">
          {{item}}: My Element 
      </div>`
})

[Demo Plunkr][1]

But as soon as I increased the array size more than 10, I start getting below error. Which is really annoying.

zone.js@0.6.25?main=browser:355 Unhandled Promise rejection: Unsupported number of argument for pure functions: 11 ; Zone: <root> ; Task: Promise.then ; Value: Error: Unsupported number of argument for pure functions: 11(…) Error: Unsupported number of argument for pure functions: 11

Template

<div *ngFor="let item of [1,2,3,4,5,6,7,8,9,10,11]">
  {{item}}
</div>`

Expected behavior

I’m curious to know why that error is happening as soon as array size increase more than 10? But another interesting thing is when I put the same array in component inside variable items= [1,2,3,4,5,6,7,8,9,10,11] and used items in *ngFor and it got worked.

  • Angular version: 2.0.1

  • Browser: all

  • Language: TypeScript

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
tboschcommented, Apr 12, 2017

This is working now in Angular 4.

0reactions
angular-automatic-lock-bot[bot]commented, Sep 11, 2019

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 2 *ngFor only supports to add 10 elements at a time in ...
This is just a limitation of the Angular2 template parser to avoid complexity in the parser (by design). It's usually a good idea...
Read more >
Angular ngFor - Learn All Features, Not Only For Arrays
Let's learn a ton of hidden ngFor features that are not often mentioned, but mot of all we are going to learn how...
Read more >
NgForOf - Angular
A structural directive that renders a template for each item in a collection. The directive is placed on an element, which becomes the...
Read more >
Angular NgFor, <ng-template> - the complete guide
In this post you're going to learn how to use Angular's NgFor directive to loop over data to render data or components.
Read more >
48 answers on StackOverflow to the most popular Angular ...
What is the Angular equivalent to an AngularJS $watch? Importing lodash into angular2 + typescript application; How to detect a route change in ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found