错误错误:未捕获(承诺)的nb-card-header'不是已知元素:

时间:2019-08-09 13:46:52

标签: angular typescript ngx-admin

我对NGX-Template和Angular非常陌生。我正在前进,但遇到了问题。

我创建了一个新页面:客户。在此页面中,我要渲染一个nb卡元素

[0, 0, 0, 9, 0, 0, 10, 0, 0]

在客户模块中,我导入了主题和nbcardmodule

  <div *ngFor="let customer of values" class="col-md-12 col-lg-6 col-xxxl-6">
    <nb-card>
        <nb-card-header>{{customer.name}}</nb-card-header>
          <nb-card-body>
            <p>Beautifull body</p>
          </nb-card-body>
        <nb-card-footer>Good customer</nb-card-footer>
        </nb-card>
  </div>
</div>

最后要完成我的customer.component.ts文件

import { ThemeModule } from '../../@theme/theme.module';
import {
  NbButtonModule,
  NbCardModule,
  NbProgressBarModule,
  NbTabsetModule,
  NbUserModule,
  NbIconModule,
  NbSelectModule,
  NbListModule,
} from '@nebular/theme';
import { CustomerRoutingModule } from './customer-routing.module';
import { CustomerCardComponent } from './customer-card/customer-card.component';
import {CustomerComponent } from './customer.component';

@NgModule({
  imports: [
    NbButtonModule,
    NbCardModule,
    NbProgressBarModule,
    NbTabsetModule,
    NbUserModule,
    NbIconModule,
    NbSelectModule,
    NbListModule,
    ThemeModule,
    CustomerRoutingModule,
  ],
  declarations: [
    CustomerCardComponent, CustomerComponent  ],

})
export class CustomerModule {}

这是控制台提供的错误

import { Component, OnInit } from '@angular/core';
import { Customer } from '../../@core/models/customer.model';
import { CustomerService } from '../../@core/services/customer.service'

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

  public message: string;
  public values: any[];

  constructor(private customerService: CustomerService){}

  ngOnInit() {
    this.customerService.getAll<Customer[]>().subscribe((data: Customer[]) => this.values = data, error => () => {
      this.message = 'Error: Could not get the data from the service';
    },
    () => {
      this.message = 'succes';
    });

  }
}

所以我希望有人可以向正确的方向推动我。我确定这是我忽略的一件事。

提前谢谢! :-)

1 个答案:

答案 0 :(得分:0)

没关系...我已经在我的pages.module中声明了我的Customer组件。因此,它被声明为double(请参见上面的Customer.Module.ts)。

我已经删除了customer.module,并且一切正常。