1

I am new to angular. Just learning it. I want to bind data with ngFor. but its not showing any data. Kindly help me to solve this

html file :

 <tbody class="text-center">
          <tr *ngFor="let agent of agentlist ;let i = index">
              <td>{{i + 1 + paginationObject?.page * paginationObject?.itemPerPage}}</td>-->
              <td>{{agent?.id?agent?.id:''}}</td>
          </tr>
        </tbody>

error : <!--bindings={ "ng-reflect-ng-for-of": null }-->

3
  • Did you tried removing the '-->' at the end of the first Table Cell?, Also you have and error on the second table cell on id? it seems you miss the dot after id?. Well Itś seem you have repeated agent?.id Commented Jul 28, 2021 at 18:25
  • Yes have try this. But its not working Commented Jul 28, 2021 at 18:29
  • Check my next answer to see if resolve your issue, Commented Jul 28, 2021 at 18:34

1 Answer 1

1

Try removing the --> at the end of the first table cell and correct the binding on the second one.

<tbody class="text-center">
  <tr *ngFor="let agent of agentlist ;let i = index">
      <td>{{i + 1 + paginationObject?.page * paginationObject?.itemPerPage}}</td>-->
      <td>{{agent?.id}}</td>
  </tr>
</tbody>

Also, you need to make sure that agentlist has something to iterate. maybe putting a console.log(agentlist) and see what it has inside of it in the ts class. If angelist is only declared but never defined you will get that error. Initialize angelist as an empty array to make sure that have an iterable before defining with the final data.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.