'ngbd-modal-component'不是一个已知的元素

时间:2019-01-07 14:44:25

标签: angular angular6 ng-bootstrap

我正在尝试在我的代码中实现NgbModal,但是我仍然遇到相同的错误: “ ngbd-modal-component”不是已知元素。

这可能是我忘记的愚蠢之举,但是我为此感到震惊。有人可以指出我正确的方向吗?

Core.module

import requests
from bs4 import BeautifulSoup
import json
import re
import pandas as pd

url = "https://www.daraz.pk/catalog/?q=dell&_keyori=ss&from=input&spm=a2a0e.home.search.go.35e34937qjElRf"



page = requests.get(url)

#print(page.status_code)
#print(page.text)
soup = BeautifulSoup(page.text, 'html.parser')
#(soup.prettify())

alpha = soup.find_all('script',{'type':'application/ld+json'})
jsonObj = json.loads(alpha[1].text)


results = pd.DataFrame()
for item in jsonObj['itemListElement']:
    name = item['name']
    price = item['offers']['price']
    currency = item['offers']['priceCurrency']
    availability = item['offers']['availability'].split('/')[-1]
    availability = [s for s in re.split("([A-Z][^A-Z]*)", availability) if s]
    availability = ' '.join(availability)

    row = [name,price,currency,availability]
    temp_df = pd.DataFrame([row], columns = ['name','price','currency','availability'])

    results = results.append(temp_df)

results.to_csv('products.csv', index=False)

组件

import { NgModule, Optional, SkipSelf } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { NgSelectModule } from '@ng-select/ng-select';
import { NgbModule, NgbModalModule } from '@ng-bootstrap/ng-bootstrap';

import { NavComponent } from './components/nav/nav.component';
import { SpinnerComponent } from './shared/components/spinner/spinner.component';
import { LoggerService } from './services/logger.service';
import { throwIfAlreadyLoaded } from './guards/module-import.guard';
import { NgbdModalComponent, NgbdModalContent } from './shared/components/config-modal/config-modal.components';

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    NgSelectModule,
    NgbModalModule,
    NgbModule.forRoot()
  ],
  entryComponents: [NgbdModalContent],
  exports: [NavComponent, FormsModule],
  declarations: [NavComponent, SpinnerComponent, NgbdModalComponent, NgbdModalContent],
  providers: [LoggerService]
})
export class CoreModule {
  constructor( @Optional() @SkipSelf() parentModule: CoreModule) {
    throwIfAlreadyLoaded(parentModule, 'CoreModule');
  }
}

1 个答案:

答案 0 :(得分:2)

将其添加到core.module中的导出中:

exports: [NavComponent, FormsModule, NgbModalModule],

编辑

抱歉,我没有意识到NgbdModalComponent是自定义组件。尝试导出它而不是导出模块:

exports: [NavComponent, FormsModule, NgbdModalComponent],