Shinji
Shinji

Reputation: 33

Ngx-Datatable can't access row in template

i'm trying to use
<ng-template let-row="row" ngx-datatable-cell-template>
in my ngx-datatable

but i'm getting the following error:
The template context of 'DataTableColumnCellDirective' does not define a member called 'row'

Here is my complete code:

<ngx-datatable 
    class="data-table"
    [rows]="filteredItems" 
    [ngClass]="'material'" 
    [rowHeight]="'auto'" 
    [headerHeight]="50"
    [footerHeight]="50"
    [limit]="6"
    [columnMode]="'force'">

      <!-- Developer Id Column -->
      <ngx-datatable-column prop="id" name="Id"></ngx-datatable-column>
      <!-- Developer First Name Column-->
      <ngx-datatable-column prop="devFirstName" name="First Name"></ngx-datatable-column>
      <!-- Developer Last Name Column -->
      <ngx-datatable-column prop="devLastName" name="Last Name"></ngx-datatable-column>
      <!-- Developer Last Name Column -->
      <ngx-datatable-column prop="email" name="Mail"></ngx-datatable-column>
      <!-- Developer GitLab Id Column -->
      <ngx-datatable-column prop="gitlabId" name="Git Id"></ngx-datatable-column>
      <!-- Developer App Count Column-->
      <ngx-datatable-column prop="appCount" name="Apps"></ngx-datatable-column>
      <!-- Developer License Column -->
      <ngx-datatable-column prop="license" name="License"></ngx-datatable-column>
      <!-- Developer Edit Column -->
      <ngx-datatable-column name="Edit" [sortable]="false">
        <ng-template let-row="row" ngx-datatable-cell-template>
          <ion-button size="small" fill="outline" (click)="changeLicense(row.id)">Edit</ion-button>
        </ng-template>
      </ngx-datatable-column>  
</ngx-datatable>

Does anyone know what i'm doing wrong?

Thanks in advance!

Upvotes: 2

Views: 2049

Answers (1)

Aleks25
Aleks25

Reputation: 91

Additional info: Issue is resolved with v0.900.8 of Angular Language Service

If you are using VS Code as Code Editor there is an issue with Angular Language Service versions greater than v0.900.4 running in VS Code and directives using ng-templates. The code should compile and work even if the language service gives you an error.

There is an open issue for this

https://github.com/angular/vscode-ng-language-service/issues/572

You can follow the example given in this answer until the issue is resolved which is to downgrade your Angular Language Service to v0.900.4 by going to extensions tab and search for Angular Language Service. Click on the Manage button next to the extension and select Install Another Version. Then select version v0.900.4.

Upvotes: 2

Related Questions