angular2 ngFor not working while fetching data from api on ngOnInit()

后端 未结 6 480
别跟我提以往
别跟我提以往 2021-01-13 03:42

comment.component.ts:

import { Component, OnInit } from \'@angular/core\';
import { Router} from \'@angular/router\'
import { Comment } from         


        
6条回答
  •  暖寄归人
    2021-01-13 04:27

    One solution would be to only display your ul once your comments have been loaded, which would then force a refresh. So something like:

    • {{comment.Name}}

    So once comments has been loaded, Angular will force a refresh, and the ul will be added to the DOM, at which point it will have all the data it needs to bind an li per comment.

提交回复
热议问题