Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i was installed all the required npm links and checked everything in app-modules & components.ts file.Still the error not rectified.Plz help me out in solving this.

What I have tried:

Trying to implement data tables in angular15.


-----------
<div class="card-container">
    <h1 class="mb-5">Angular DataTable Tutorial With Example | ScratchCode.io</h1>
 
    <table datatable [dtoption]="dtoption" class="row-border hover">
        <thead>
            <tr>
                <th>ID</th>
 
                <th>Title</th>
 
                <th>Body</th>
            </tr>
        </thead>
 
        <tbody>
            <tr *ngFor="let post of posts">
                <td>{{ post.id }}</td>
 
                <td>{{ post.title }}</td>
 
                <td>{{ post.body }}</td>
            </tr>
        </tbody>
    </table>
</div>
-----




----------
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';

@Component({
  selector: 'app-tables',
  templateUrl: './tables.component.html',
  styleUrls: ['./tables.component.scss']
})
export class TablesComponent implements OnInit{

  title = 'tables';
 
  dtOptions: DataTables.Settings = {};
  posts: any;
 
  constructor(private http: HttpClient) {
 
    this.http.get('http://jsonplaceholder.typicode.com/posts')
      .subscribe(posts => {
        this.posts = posts;
    }, error => console.error(error));
  }
 
  ngOnInit(): void {
    this.dtOptions = {
      pagingType: 'full_numbers',
      pageLength: 5,
      processing: true
    };
  }
   


  

  
  
  }
------------

-----
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { TablesComponent } from './tables/tables.component';
import { DataTablesModule} from 'angular-datatables';
import { CommonModule } from '@angular/common';

@NgModule({
  declarations: [
    AppComponent,
    TablesComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,DataTablesModule.forRoot(),CommonModule,
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
-----


{it's not showing any error except dtoption not binded with tables.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900