Iteration in Angular 2 + Immutable.js (using * ngFor)

I am using Angular 2 with Immutable JS, but I cannot get a simple loop to work in my template. This is really frustrating. I tried the following old syntax (based on tutorials)

<div *ngFor='#filter of filterArray' class='filter-row'>
  <div class='row-title'>{{filter.get(title)}}</div>
</div>

and new syntax

<div *ngFor=' let filter of filterArray' class='filter-row'>
  <div class='row-title'>{{filter.get(title)}}</div>
</div>

I tried with .get syntax and without syntax for immutable cards in braces, and I just can't get it to work.

filterArray looks like this:

this.filterArray = fromJS([{
  title: 'Brand',
},
{
  title: 'Category'
},
{
  title: 'Each UPC'
}]);

Is there any special syntax that I need to use for this to work? Nothing is displayed in my browser and I am not getting errors when using let syntax.

Versions:

"@angular/common": "^2.1.0",
"@angular/compiler": "^2.1.0",
"@angular/core": "^2.1.0",
"@angular/forms": "^2.1.0",
"@angular/http": "^2.1.0",
"@angular/platform-browser": "^2.1.0",
"@angular/platform-browser-dynamic": "^2.1.0",
"@angular/router": "^3.0.1",
"immutable": "^3.8.1",
"typescript": "2.0.2"

Edit: The following works, but it looks bad

  <div *ngFor='let filter of filterArray let i=index' class='filter-row'>
    <div class='row-title'>{{filterArray.get(i).get('title')}}</div>
  </div>
+4
source share
1 answer

This worked for me:

<div *ngFor='let filter of filterArray' class='filter-row'>
    <div class='row-title'>{{filter.get('title')}}</div>  
</div>
0
source

Source: https://habr.com/ru/post/1659218/


All Articles