A
A
Alexander Belov2017-04-10 00:18:58
JavaScript
Alexander Belov, 2017-04-10 00:18:58

How to break ul li ngFor render in Angular2?

Please remind me how to split ul li ngFor render in Angular2?
Render this json

{	
    "id" :"one",
    "title" :"one title",
    "autos" : [
      "E92",
      "E30",
                        "E46",
      "E36"
    ]
  }

component.ts
<div *ngIf="selectedBlock">
          <img src="{{selectedBlock.image}}"/>
          <h2>{{selectedBlock.title}}</h2>
          <h3>Autos</h3>
          <ul class="autos">
            <li>{{selectedBlock.autos}}</li>
          </ul>     
        </div>

Everything in one line so renders separated by commas -
E92, E30, E46, E36
Desired result - list down. CSS , of course, does not work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Coder321, 2017-04-10
@AlexanderBelov

<div *ngIf="selectedBlock">
          <img src="{{selectedBlock.image}}"/>
          <h2>{{selectedBlock.title}}</h2>
          <h3>Autos</h3>
          <ul class="autos">
            <li *ngFor="let auto of selectedBlock.autos">{{auto }}</li>
          </ul>     
        </div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question