How to check a data value for looping exist before create table header?

Dear friends,

I have a form and it’s relevant search value below it. I get the result and can show it using “ngFor”. But my doubt is how to check that looped variable exist to show the above “heading” and “header” part.

<h2>Search results</h2>
    <div class="row header">
            <div class="col">#</div>
            <div class="col">Owner</div>
            <div class="col">Door No</div>
            <div class="col"></div>
          <div class="row" *ngFor="let searchdata of result; let i = index">
            <div class="col">{{i + 1}}</div>
            <div class="col">{{searchdata.chvownerEng}} </div>
            <div class="col">{{searchdata.intWardNo}}/{{searchdata.intDoorNO}}/{{searchdata.chvDoorNOSub}}</div>
            <div class="col"><button [navPush]="payPage" [navParams]="params">Show</button></div>

So without data that HEADING and header fields show…

How to remove it ? please advise



You can do a check like that:

<div *ngIf="result.length" class="row header">

Hi wingly,

Got error as

_co.result is undefined

please advise…

Dear Wingly ,

Got the solution using

<div *ngIf="result?.length > 0" class="row header">

Thanks for your support