0

angular2 smart table is not showing the table. I have followed the link git hub

app.module.ts

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { AppComponent }  from './app.component';
import { Ng2SmartTableModule } from 'ng2-smart-table';
@NgModule({
    imports: [BrowserModule, FormsModule, Ng2SmartTableModule],
    declarations: [AppComponent],
    bootstrap: [AppComponent]

})
export class AppModule { }

request.component.ts

import { Component } from '@angular/core';
import { ItableValues } from './tableValues.component';
import { RequestFilterPipe } from './request-filter.pipe';
import { TableService } from './table-service.component';
@Component({
    selector: 'mm-request',
    templateUrl: 'app/dataManagement/request.component.html',
 
})

export class RequestComponent  {
    pageTitle: string = 'Request';
    imageWidth: number = 50;
    imageMargin: number = 2;
   
    settings = {
        columns: {
            id: {
                title: 'ID'
            },
            name: {
                title: 'Full Name'
            },
            username: {
                title: 'User Name'
            },
            email: {
                title: 'Email'
            }
        }
    };
    data = [
        {
            id: 1,
            name: "Leanne Graham",
            username: "Bret",
            email: "Sincere@april.biz"
        },
        {
            id: 2,
            name: "Ervin Howell",
            username: "Antonette",
            email: "Shanna@melissa.tv"
        },

        // ... list of items

        {
            id: 11,
            name: "Nicholas DuBuque",
            username: "Nicholas.Stanton",
            email: "Rey.Padberg@rosamond.biz"
        }
    ];

}

request.component.html

<div>
    <ng2-smart-table [settings]="settings" [source]="data"></ng2-smart-table>
</div>

Whenever i run the application, it shows only the first Loading page. enter image description here All help will be appreciated.

UPDATE: I have removed Ng2SmartTableModule used in declarartion as well as in bootstrap. It is used for a testing. please see the console log and error main.js file. enter image description here

Error loading http://localhost:53869/app/main.js

"use strict";
var app_module_1 = require('./app.module');
var platform_browser_dynamic_1 = require('@angular/platform-browser-dynamic');
platform_browser_dynamic_1.platformBrowserDynamic().bootstrapModule(app_module_1.AppModule);
//# sourceMappingURL=main.js.map
Sarat
  • 271
  • 5
  • 22

1 Answers1

0

open your console then read your error log first.

bootstrap array and declarations array should not include this one Ng2SmartTableModule

please read this first:

NgModule is a decorator function that takes a single metadata object whose properties describe the module. The most important properties are:

declarations - the view classes that belong to this module. Angular has three kinds of view classes: components, directives, and pipes.

exports - the subset of declarations that should be visible and usable in the component templates of other modules.

imports - other modules whose exported classes are needed by component templates declared in this module.

providers - creators of services that this module contributes to the global collection of services; they become accessible in all parts of the app.

bootstrap - the main application view, called the root component, that hosts all other app views. Only the root module should set this bootstrap property.

https://angular.io/guide/architecture

Tiep Phan
  • 12,386
  • 3
  • 38
  • 41