【问题标题】:angular2 smart table is not workingangular2 智能表不工作
【发布时间】:2017-06-19 21:58:17
【问题描述】:

angular2 智能表未显示该表。我已经关注链接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>

每当我运行应用程序时,它只显示第一个加载页面。 我们将不胜感激。

更新: 我删除了声明和引导程序中使用的 Ng2SmartTableModule。它用于测试。请查看控制台日志和错误 main.js 文件。

加载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

【问题讨论】:

    标签: angular ng2-smart-table


    【解决方案1】:

    打开您的控制台,然后先阅读您的错误日志。

    bootstrap 数组和declarations 数组不应包含这个Ng2SmartTableModule

    请先阅读:

    NgModule 是一个装饰器函数,它采用单个元数据对象 其属性描述模块。最重要的属性 是:

    declarations - 属于该模块的视图类。角 有三种视图类:components、directives和pipes。

    exports - 应该可见和可用的声明子集 在其他模块的组件模板中。

    imports - 组件需要其导出类的其他模块 此模块中声明的模板。

    providers - 此模块贡献的服务的创建者 全球服务集合;它们在所有地方都可以访问 应用程序。

    bootstrap - 主应用程序视图,称为根组件,它 托管所有其他应用程序视图。只有根模块应该设置这个 引导属性。

    https://angular.io/guide/architecture

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-20
      • 1970-01-01
      • 1970-01-01
      • 2018-07-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多