如何正确导入角度模块?无法弄清楚我缺少哪一件。

时间:2017-10-05 21:52:02

标签: angular typescript primeng angular-module

在多个模块中调用PrimeNg引用是否有问题?或者我应该在共享模块中使用它?那里有最好的做法吗? 似乎我没有从primeng导入“p-dataTable”,但我确实在声明组件的模块中有它。

错误我在validation.component.html中引用了我的html:

errors.ts:42 ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'value' since it isn't a known property of 'p-dataTable'.
1. If 'p-dataTable' is an Angular component and it has 'value' input, then verify that it is part of this module.
2. If 'p-dataTable' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the @NgModule.schemas' of this component. ("
<body>
    <h3>Validation tabs go here.</h3>
    <p-dataTable [ERROR ->][value]="validationsList" selectionMode="single" [(selection)]="selectedValidation" dataKey="id"
    "): ng:///app/validation/validation.component.html@7:17

我有validation.module.ts

import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { SharedModule } from "../shared/shared.module";
import { ValidationComponent } from "./validation.component";
import { SampleIdsTableComponent } from "./sampleIdsTable.component";
import { AllTestsComponent } from "./allTests.component";
import { RunStatusComponent } from "./runStatus.component";
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { NglModule } from 'ng-lightning/ng-lightning';
import {
SharedModule as Prime_SharedModule,
TabMenuModule, AccordionModule, MenuModule, MenubarModule,     SelectButtonModule,
CalendarModule, InputTextareaModule, DataTableModule, ChartModule, DataGridModule
} from 'primeng/primeng';

@NgModule({
imports: [
    SharedModule,
    RouterModule.forChild([
        {
            path: '',
            component: ValidationComponent,
            children: [
                {
                    path: '',
                    pathMatch: 'full'
                },
                {
                    path: 'samples',
                    component: SampleIdsTableComponent
                },
                {
                    path: 'allTests',
                    component: AllTestsComponent
                },
                {
                    path: 'runStatus',
                    component: RunStatusComponent
                }
            ]

        },
        Prime_SharedModule,
        TabMenuModule,
        NgbModule.forRoot(),
        NglModule.forRoot(),
        AccordionModule,
        DataTableModule,
        MenuModule,
        MenubarModule,
        SelectButtonModule,
        CalendarModule,
        ChartModule,
        InputTextareaModule,
        DataGridModule
    ])
],
declarations: [
    ValidationComponent,
    SampleIdsTableComponent,
    AllTestsComponent,
    RunStatusComponent
],
providers: [
]
})
export class ValidationModule { }

1 个答案:

答案 0 :(得分:0)

支架!计算括号。我将所有导入添加到RouterModule.forChild([...])而不是imports数组。