Selector 角度5-选择器不';当从另一个组件调用时,t paint component.html

Selector 角度5-选择器不';当从另一个组件调用时,t paint component.html,selector,angular2-template,Selector,Angular2 Template,所以我有两个组件,ChartsComponent(渲染图表)& DataComponent(在其他数据、表格等中显示图表) 文件系统如下所示: 应用程序/图表/ 应用程序/实体/数据/ ChartsComponent在使用自己的路由呈现到自己的页面时成功呈现。DataComponent可以工作,但无法通过选择器呈现ChartsComponent。控制台显示完全没有错误。我尝试在DataComponent中调用ChartsComponent的选择器,如下所示: data.component.htm

所以我有两个组件,ChartsComponent(渲染图表)& DataComponent(在其他数据、表格等中显示图表)

文件系统如下所示:

应用程序/图表/

应用程序/实体/数据/

ChartsComponent在使用自己的路由呈现到自己的页面时成功呈现。DataComponent可以工作,但无法通过选择器呈现ChartsComponent。控制台显示完全没有错误。我尝试在DataComponent中调用ChartsComponent的选择器,如下所示:

data.component.html

<chart-data></chart-data>
<div [chart]="chart1"></div>
import { Component, OnInit} from '@angular/core';
import { Chart } from 'angular-highcharts';
//I'm loading data into the chart statically for trial
import { jsonData} from '../json-data/chart-data';

@Component({
  selector: 'chart-data',
  templateUrl: './charts.component.html'
})
export class ChartsComponent implements OnInit{

  //Chart
  chart1: Chart;
  countries: any;
  num: any;
  chartData: any;

  constructor() {
    this.barChart();
  }

  ngOnInit(){}

  barChart(){
    this.chartData = jsonData;
    this.chart1 = new Chart(this.chartData);
  }
}
import { Component, OnInit, OnDestroy } from '@angular/core';
import { HttpResponse, HttpErrorResponse } from '@angular/common/http';
import { ActivatedRoute, Router } from '@angular/router';
import { DataService } from './provision.service';
import { ChartsComponent } from '../../charts/charts.component';

@Component({
    selector: 'data-page',
    templateUrl: './data.component.html'
})

export class DataComponent implements OnInit, OnDestroy {

}
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { ChartsComponent } from './';

@NgModule({
    declarations: [
        ChartsComponent
    ],
    exports: [
        ChartsComponent
    ]
})

export class ChartsModule {}
import { RouterModule } from '@angular/router';
import { ChartsModule } from '../../charts';
import { ChartsComponent } from '../../charts/charts.component';

import {
    DataService,
    DataComponent,
    DataRoute
} from './';

@NgModule({
    imports: [],
    declarations: [DataComponent],
    entryComponents: [
        DataComponent,
        ChartsComponent
    ],
    providers: [
        DataService
    ]
})
export class DataModule {}
export * from './charts.component';
export * from './charts.module';
export * from './charts.route';
import './vendor.ts';

import { NgModule, Injector } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { Ng2Webstorage, LocalStorageService, SessionStorageService  } from 'ngx-webstorage';
import { EventManager } from 'ng-blahblah';

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ChartModule } from 'angular-highcharts';
import { ChartsComponent } from './charts';


import { AuthInterceptor } from './blocks/interceptor/auth.interceptor';
import { AuthExpiredInterceptor } from './blocks/interceptor/auth-expired.interceptor';
import { ErrorHandlerInterceptor } from './blocks/interceptor/errorhandler.interceptor';
import { NotificationInterceptor } from './blocks/interceptor/notification.interceptor';
import { SharedModule, UserRouteAccessService } from './shared';
import { AppRoutingModule} from './app-routing.module';
import { HomeModule } from './home/home.module';
import { AdminModule } from './admin/admin.module';
import { AccountModule } from './account/account.module';
import { EntityModule } from './entities/entity.module';
import { PaginationConfig } from './blocks/config/uib-pagination.config';
import {
    MainComponent,
    NavbarComponent,
    FooterComponent,
    ProfileService,
    PageRibbonComponent,
    ActiveMenuDirective,
    ErrorComponent
} from './layouts';

@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        AppRoutingModule,
        SharedModule,
        HomeModule
        EntityModule,
        ChartModule
    ],
    declarations: [
        MainComponent,
        NavbarComponent,
        ErrorComponent,
        PageRibbonComponent,
        ActiveMenuDirective,
        FooterComponent,
        ChartsComponent
    ],
    providers: [
        ProfileService,
        PaginationConfig,
        UserRouteAccessService,
        {
            provide: HTTP_INTERCEPTORS,
            useClass: AuthInterceptor,
            multi: true,
            deps: [
                LocalStorageService,
                SessionStorageService
            ]
        },
        {
            provide: HTTP_INTERCEPTORS,
            useClass: AuthExpiredInterceptor,
            multi: true,
            deps: [
                Injector
            ]
        },
        {
            provide: HTTP_INTERCEPTORS,
            useClass: ErrorHandlerInterceptor,
            multi: true,
            deps: [
                EventManager
            ]
        },
        {
            provide: HTTP_INTERCEPTORS,
            useClass: NotificationInterceptor,
            multi: true,
            deps: [
                Injector
            ]
        },
        /*{
            provide: NgbDateParserFormatter,
            useFactory: () => { return new NgbDateMomentParserFormatter("DD-MM-YYYY") }
        }*/
    ],
    bootstrap: [ MainComponent ]
})
export class AppModule {}
data.component.ts

<chart-data></chart-data>
<div [chart]="chart1"></div>
import { Component, OnInit} from '@angular/core';
import { Chart } from 'angular-highcharts';
//I'm loading data into the chart statically for trial
import { jsonData} from '../json-data/chart-data';

@Component({
  selector: 'chart-data',
  templateUrl: './charts.component.html'
})
export class ChartsComponent implements OnInit{

  //Chart
  chart1: Chart;
  countries: any;
  num: any;
  chartData: any;

  constructor() {
    this.barChart();
  }

  ngOnInit(){}

  barChart(){
    this.chartData = jsonData;
    this.chart1 = new Chart(this.chartData);
  }
}
import { Component, OnInit, OnDestroy } from '@angular/core';
import { HttpResponse, HttpErrorResponse } from '@angular/common/http';
import { ActivatedRoute, Router } from '@angular/router';
import { DataService } from './provision.service';
import { ChartsComponent } from '../../charts/charts.component';

@Component({
    selector: 'data-page',
    templateUrl: './data.component.html'
})

export class DataComponent implements OnInit, OnDestroy {

}
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { ChartsComponent } from './';

@NgModule({
    declarations: [
        ChartsComponent
    ],
    exports: [
        ChartsComponent
    ]
})

export class ChartsModule {}
import { RouterModule } from '@angular/router';
import { ChartsModule } from '../../charts';
import { ChartsComponent } from '../../charts/charts.component';

import {
    DataService,
    DataComponent,
    DataRoute
} from './';

@NgModule({
    imports: [],
    declarations: [DataComponent],
    entryComponents: [
        DataComponent,
        ChartsComponent
    ],
    providers: [
        DataService
    ]
})
export class DataModule {}
export * from './charts.component';
export * from './charts.module';
export * from './charts.route';
import './vendor.ts';

import { NgModule, Injector } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { Ng2Webstorage, LocalStorageService, SessionStorageService  } from 'ngx-webstorage';
import { EventManager } from 'ng-blahblah';

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ChartModule } from 'angular-highcharts';
import { ChartsComponent } from './charts';


import { AuthInterceptor } from './blocks/interceptor/auth.interceptor';
import { AuthExpiredInterceptor } from './blocks/interceptor/auth-expired.interceptor';
import { ErrorHandlerInterceptor } from './blocks/interceptor/errorhandler.interceptor';
import { NotificationInterceptor } from './blocks/interceptor/notification.interceptor';
import { SharedModule, UserRouteAccessService } from './shared';
import { AppRoutingModule} from './app-routing.module';
import { HomeModule } from './home/home.module';
import { AdminModule } from './admin/admin.module';
import { AccountModule } from './account/account.module';
import { EntityModule } from './entities/entity.module';
import { PaginationConfig } from './blocks/config/uib-pagination.config';
import {
    MainComponent,
    NavbarComponent,
    FooterComponent,
    ProfileService,
    PageRibbonComponent,
    ActiveMenuDirective,
    ErrorComponent
} from './layouts';

@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        AppRoutingModule,
        SharedModule,
        HomeModule
        EntityModule,
        ChartModule
    ],
    declarations: [
        MainComponent,
        NavbarComponent,
        ErrorComponent,
        PageRibbonComponent,
        ActiveMenuDirective,
        FooterComponent,
        ChartsComponent
    ],
    providers: [
        ProfileService,
        PaginationConfig,
        UserRouteAccessService,
        {
            provide: HTTP_INTERCEPTORS,
            useClass: AuthInterceptor,
            multi: true,
            deps: [
                LocalStorageService,
                SessionStorageService
            ]
        },
        {
            provide: HTTP_INTERCEPTORS,
            useClass: AuthExpiredInterceptor,
            multi: true,
            deps: [
                Injector
            ]
        },
        {
            provide: HTTP_INTERCEPTORS,
            useClass: ErrorHandlerInterceptor,
            multi: true,
            deps: [
                EventManager
            ]
        },
        {
            provide: HTTP_INTERCEPTORS,
            useClass: NotificationInterceptor,
            multi: true,
            deps: [
                Injector
            ]
        },
        /*{
            provide: NgbDateParserFormatter,
            useFactory: () => { return new NgbDateMomentParserFormatter("DD-MM-YYYY") }
        }*/
    ],
    bootstrap: [ MainComponent ]
})
export class AppModule {}
图表.模块.ts

<chart-data></chart-data>
<div [chart]="chart1"></div>
import { Component, OnInit} from '@angular/core';
import { Chart } from 'angular-highcharts';
//I'm loading data into the chart statically for trial
import { jsonData} from '../json-data/chart-data';

@Component({
  selector: 'chart-data',
  templateUrl: './charts.component.html'
})
export class ChartsComponent implements OnInit{

  //Chart
  chart1: Chart;
  countries: any;
  num: any;
  chartData: any;

  constructor() {
    this.barChart();
  }

  ngOnInit(){}

  barChart(){
    this.chartData = jsonData;
    this.chart1 = new Chart(this.chartData);
  }
}
import { Component, OnInit, OnDestroy } from '@angular/core';
import { HttpResponse, HttpErrorResponse } from '@angular/common/http';
import { ActivatedRoute, Router } from '@angular/router';
import { DataService } from './provision.service';
import { ChartsComponent } from '../../charts/charts.component';

@Component({
    selector: 'data-page',
    templateUrl: './data.component.html'
})

export class DataComponent implements OnInit, OnDestroy {

}
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { ChartsComponent } from './';

@NgModule({
    declarations: [
        ChartsComponent
    ],
    exports: [
        ChartsComponent
    ]
})

export class ChartsModule {}
import { RouterModule } from '@angular/router';
import { ChartsModule } from '../../charts';
import { ChartsComponent } from '../../charts/charts.component';

import {
    DataService,
    DataComponent,
    DataRoute
} from './';

@NgModule({
    imports: [],
    declarations: [DataComponent],
    entryComponents: [
        DataComponent,
        ChartsComponent
    ],
    providers: [
        DataService
    ]
})
export class DataModule {}
export * from './charts.component';
export * from './charts.module';
export * from './charts.route';
import './vendor.ts';

import { NgModule, Injector } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { Ng2Webstorage, LocalStorageService, SessionStorageService  } from 'ngx-webstorage';
import { EventManager } from 'ng-blahblah';

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ChartModule } from 'angular-highcharts';
import { ChartsComponent } from './charts';


import { AuthInterceptor } from './blocks/interceptor/auth.interceptor';
import { AuthExpiredInterceptor } from './blocks/interceptor/auth-expired.interceptor';
import { ErrorHandlerInterceptor } from './blocks/interceptor/errorhandler.interceptor';
import { NotificationInterceptor } from './blocks/interceptor/notification.interceptor';
import { SharedModule, UserRouteAccessService } from './shared';
import { AppRoutingModule} from './app-routing.module';
import { HomeModule } from './home/home.module';
import { AdminModule } from './admin/admin.module';
import { AccountModule } from './account/account.module';
import { EntityModule } from './entities/entity.module';
import { PaginationConfig } from './blocks/config/uib-pagination.config';
import {
    MainComponent,
    NavbarComponent,
    FooterComponent,
    ProfileService,
    PageRibbonComponent,
    ActiveMenuDirective,
    ErrorComponent
} from './layouts';

@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        AppRoutingModule,
        SharedModule,
        HomeModule
        EntityModule,
        ChartModule
    ],
    declarations: [
        MainComponent,
        NavbarComponent,
        ErrorComponent,
        PageRibbonComponent,
        ActiveMenuDirective,
        FooterComponent,
        ChartsComponent
    ],
    providers: [
        ProfileService,
        PaginationConfig,
        UserRouteAccessService,
        {
            provide: HTTP_INTERCEPTORS,
            useClass: AuthInterceptor,
            multi: true,
            deps: [
                LocalStorageService,
                SessionStorageService
            ]
        },
        {
            provide: HTTP_INTERCEPTORS,
            useClass: AuthExpiredInterceptor,
            multi: true,
            deps: [
                Injector
            ]
        },
        {
            provide: HTTP_INTERCEPTORS,
            useClass: ErrorHandlerInterceptor,
            multi: true,
            deps: [
                EventManager
            ]
        },
        {
            provide: HTTP_INTERCEPTORS,
            useClass: NotificationInterceptor,
            multi: true,
            deps: [
                Injector
            ]
        },
        /*{
            provide: NgbDateParserFormatter,
            useFactory: () => { return new NgbDateMomentParserFormatter("DD-MM-YYYY") }
        }*/
    ],
    bootstrap: [ MainComponent ]
})
export class AppModule {}
数据模块.ts

<chart-data></chart-data>
<div [chart]="chart1"></div>
import { Component, OnInit} from '@angular/core';
import { Chart } from 'angular-highcharts';
//I'm loading data into the chart statically for trial
import { jsonData} from '../json-data/chart-data';

@Component({
  selector: 'chart-data',
  templateUrl: './charts.component.html'
})
export class ChartsComponent implements OnInit{

  //Chart
  chart1: Chart;
  countries: any;
  num: any;
  chartData: any;

  constructor() {
    this.barChart();
  }

  ngOnInit(){}

  barChart(){
    this.chartData = jsonData;
    this.chart1 = new Chart(this.chartData);
  }
}
import { Component, OnInit, OnDestroy } from '@angular/core';
import { HttpResponse, HttpErrorResponse } from '@angular/common/http';
import { ActivatedRoute, Router } from '@angular/router';
import { DataService } from './provision.service';
import { ChartsComponent } from '../../charts/charts.component';

@Component({
    selector: 'data-page',
    templateUrl: './data.component.html'
})

export class DataComponent implements OnInit, OnDestroy {

}
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { ChartsComponent } from './';

@NgModule({
    declarations: [
        ChartsComponent
    ],
    exports: [
        ChartsComponent
    ]
})

export class ChartsModule {}
import { RouterModule } from '@angular/router';
import { ChartsModule } from '../../charts';
import { ChartsComponent } from '../../charts/charts.component';

import {
    DataService,
    DataComponent,
    DataRoute
} from './';

@NgModule({
    imports: [],
    declarations: [DataComponent],
    entryComponents: [
        DataComponent,
        ChartsComponent
    ],
    providers: [
        DataService
    ]
})
export class DataModule {}
export * from './charts.component';
export * from './charts.module';
export * from './charts.route';
import './vendor.ts';

import { NgModule, Injector } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { Ng2Webstorage, LocalStorageService, SessionStorageService  } from 'ngx-webstorage';
import { EventManager } from 'ng-blahblah';

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ChartModule } from 'angular-highcharts';
import { ChartsComponent } from './charts';


import { AuthInterceptor } from './blocks/interceptor/auth.interceptor';
import { AuthExpiredInterceptor } from './blocks/interceptor/auth-expired.interceptor';
import { ErrorHandlerInterceptor } from './blocks/interceptor/errorhandler.interceptor';
import { NotificationInterceptor } from './blocks/interceptor/notification.interceptor';
import { SharedModule, UserRouteAccessService } from './shared';
import { AppRoutingModule} from './app-routing.module';
import { HomeModule } from './home/home.module';
import { AdminModule } from './admin/admin.module';
import { AccountModule } from './account/account.module';
import { EntityModule } from './entities/entity.module';
import { PaginationConfig } from './blocks/config/uib-pagination.config';
import {
    MainComponent,
    NavbarComponent,
    FooterComponent,
    ProfileService,
    PageRibbonComponent,
    ActiveMenuDirective,
    ErrorComponent
} from './layouts';

@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        AppRoutingModule,
        SharedModule,
        HomeModule
        EntityModule,
        ChartModule
    ],
    declarations: [
        MainComponent,
        NavbarComponent,
        ErrorComponent,
        PageRibbonComponent,
        ActiveMenuDirective,
        FooterComponent,
        ChartsComponent
    ],
    providers: [
        ProfileService,
        PaginationConfig,
        UserRouteAccessService,
        {
            provide: HTTP_INTERCEPTORS,
            useClass: AuthInterceptor,
            multi: true,
            deps: [
                LocalStorageService,
                SessionStorageService
            ]
        },
        {
            provide: HTTP_INTERCEPTORS,
            useClass: AuthExpiredInterceptor,
            multi: true,
            deps: [
                Injector
            ]
        },
        {
            provide: HTTP_INTERCEPTORS,
            useClass: ErrorHandlerInterceptor,
            multi: true,
            deps: [
                EventManager
            ]
        },
        {
            provide: HTTP_INTERCEPTORS,
            useClass: NotificationInterceptor,
            multi: true,
            deps: [
                Injector
            ]
        },
        /*{
            provide: NgbDateParserFormatter,
            useFactory: () => { return new NgbDateMomentParserFormatter("DD-MM-YYYY") }
        }*/
    ],
    bootstrap: [ MainComponent ]
})
export class AppModule {}
图表/索引.ts

<chart-data></chart-data>
<div [chart]="chart1"></div>
import { Component, OnInit} from '@angular/core';
import { Chart } from 'angular-highcharts';
//I'm loading data into the chart statically for trial
import { jsonData} from '../json-data/chart-data';

@Component({
  selector: 'chart-data',
  templateUrl: './charts.component.html'
})
export class ChartsComponent implements OnInit{

  //Chart
  chart1: Chart;
  countries: any;
  num: any;
  chartData: any;

  constructor() {
    this.barChart();
  }

  ngOnInit(){}

  barChart(){
    this.chartData = jsonData;
    this.chart1 = new Chart(this.chartData);
  }
}
import { Component, OnInit, OnDestroy } from '@angular/core';
import { HttpResponse, HttpErrorResponse } from '@angular/common/http';
import { ActivatedRoute, Router } from '@angular/router';
import { DataService } from './provision.service';
import { ChartsComponent } from '../../charts/charts.component';

@Component({
    selector: 'data-page',
    templateUrl: './data.component.html'
})

export class DataComponent implements OnInit, OnDestroy {

}
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { ChartsComponent } from './';

@NgModule({
    declarations: [
        ChartsComponent
    ],
    exports: [
        ChartsComponent
    ]
})

export class ChartsModule {}
import { RouterModule } from '@angular/router';
import { ChartsModule } from '../../charts';
import { ChartsComponent } from '../../charts/charts.component';

import {
    DataService,
    DataComponent,
    DataRoute
} from './';

@NgModule({
    imports: [],
    declarations: [DataComponent],
    entryComponents: [
        DataComponent,
        ChartsComponent
    ],
    providers: [
        DataService
    ]
})
export class DataModule {}
export * from './charts.component';
export * from './charts.module';
export * from './charts.route';
import './vendor.ts';

import { NgModule, Injector } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { Ng2Webstorage, LocalStorageService, SessionStorageService  } from 'ngx-webstorage';
import { EventManager } from 'ng-blahblah';

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ChartModule } from 'angular-highcharts';
import { ChartsComponent } from './charts';


import { AuthInterceptor } from './blocks/interceptor/auth.interceptor';
import { AuthExpiredInterceptor } from './blocks/interceptor/auth-expired.interceptor';
import { ErrorHandlerInterceptor } from './blocks/interceptor/errorhandler.interceptor';
import { NotificationInterceptor } from './blocks/interceptor/notification.interceptor';
import { SharedModule, UserRouteAccessService } from './shared';
import { AppRoutingModule} from './app-routing.module';
import { HomeModule } from './home/home.module';
import { AdminModule } from './admin/admin.module';
import { AccountModule } from './account/account.module';
import { EntityModule } from './entities/entity.module';
import { PaginationConfig } from './blocks/config/uib-pagination.config';
import {
    MainComponent,
    NavbarComponent,
    FooterComponent,
    ProfileService,
    PageRibbonComponent,
    ActiveMenuDirective,
    ErrorComponent
} from './layouts';

@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        AppRoutingModule,
        SharedModule,
        HomeModule
        EntityModule,
        ChartModule
    ],
    declarations: [
        MainComponent,
        NavbarComponent,
        ErrorComponent,
        PageRibbonComponent,
        ActiveMenuDirective,
        FooterComponent,
        ChartsComponent
    ],
    providers: [
        ProfileService,
        PaginationConfig,
        UserRouteAccessService,
        {
            provide: HTTP_INTERCEPTORS,
            useClass: AuthInterceptor,
            multi: true,
            deps: [
                LocalStorageService,
                SessionStorageService
            ]
        },
        {
            provide: HTTP_INTERCEPTORS,
            useClass: AuthExpiredInterceptor,
            multi: true,
            deps: [
                Injector
            ]
        },
        {
            provide: HTTP_INTERCEPTORS,
            useClass: ErrorHandlerInterceptor,
            multi: true,
            deps: [
                EventManager
            ]
        },
        {
            provide: HTTP_INTERCEPTORS,
            useClass: NotificationInterceptor,
            multi: true,
            deps: [
                Injector
            ]
        },
        /*{
            provide: NgbDateParserFormatter,
            useFactory: () => { return new NgbDateMomentParserFormatter("DD-MM-YYYY") }
        }*/
    ],
    bootstrap: [ MainComponent ]
})
export class AppModule {}
应用程序模块.ts

<chart-data></chart-data>
<div [chart]="chart1"></div>
import { Component, OnInit} from '@angular/core';
import { Chart } from 'angular-highcharts';
//I'm loading data into the chart statically for trial
import { jsonData} from '../json-data/chart-data';

@Component({
  selector: 'chart-data',
  templateUrl: './charts.component.html'
})
export class ChartsComponent implements OnInit{

  //Chart
  chart1: Chart;
  countries: any;
  num: any;
  chartData: any;

  constructor() {
    this.barChart();
  }

  ngOnInit(){}

  barChart(){
    this.chartData = jsonData;
    this.chart1 = new Chart(this.chartData);
  }
}
import { Component, OnInit, OnDestroy } from '@angular/core';
import { HttpResponse, HttpErrorResponse } from '@angular/common/http';
import { ActivatedRoute, Router } from '@angular/router';
import { DataService } from './provision.service';
import { ChartsComponent } from '../../charts/charts.component';

@Component({
    selector: 'data-page',
    templateUrl: './data.component.html'
})

export class DataComponent implements OnInit, OnDestroy {

}
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { ChartsComponent } from './';

@NgModule({
    declarations: [
        ChartsComponent
    ],
    exports: [
        ChartsComponent
    ]
})

export class ChartsModule {}
import { RouterModule } from '@angular/router';
import { ChartsModule } from '../../charts';
import { ChartsComponent } from '../../charts/charts.component';

import {
    DataService,
    DataComponent,
    DataRoute
} from './';

@NgModule({
    imports: [],
    declarations: [DataComponent],
    entryComponents: [
        DataComponent,
        ChartsComponent
    ],
    providers: [
        DataService
    ]
})
export class DataModule {}
export * from './charts.component';
export * from './charts.module';
export * from './charts.route';
import './vendor.ts';

import { NgModule, Injector } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { Ng2Webstorage, LocalStorageService, SessionStorageService  } from 'ngx-webstorage';
import { EventManager } from 'ng-blahblah';

import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ChartModule } from 'angular-highcharts';
import { ChartsComponent } from './charts';


import { AuthInterceptor } from './blocks/interceptor/auth.interceptor';
import { AuthExpiredInterceptor } from './blocks/interceptor/auth-expired.interceptor';
import { ErrorHandlerInterceptor } from './blocks/interceptor/errorhandler.interceptor';
import { NotificationInterceptor } from './blocks/interceptor/notification.interceptor';
import { SharedModule, UserRouteAccessService } from './shared';
import { AppRoutingModule} from './app-routing.module';
import { HomeModule } from './home/home.module';
import { AdminModule } from './admin/admin.module';
import { AccountModule } from './account/account.module';
import { EntityModule } from './entities/entity.module';
import { PaginationConfig } from './blocks/config/uib-pagination.config';
import {
    MainComponent,
    NavbarComponent,
    FooterComponent,
    ProfileService,
    PageRibbonComponent,
    ActiveMenuDirective,
    ErrorComponent
} from './layouts';

@NgModule({
    imports: [
        BrowserModule,
        BrowserAnimationsModule,
        AppRoutingModule,
        SharedModule,
        HomeModule
        EntityModule,
        ChartModule
    ],
    declarations: [
        MainComponent,
        NavbarComponent,
        ErrorComponent,
        PageRibbonComponent,
        ActiveMenuDirective,
        FooterComponent,
        ChartsComponent
    ],
    providers: [
        ProfileService,
        PaginationConfig,
        UserRouteAccessService,
        {
            provide: HTTP_INTERCEPTORS,
            useClass: AuthInterceptor,
            multi: true,
            deps: [
                LocalStorageService,
                SessionStorageService
            ]
        },
        {
            provide: HTTP_INTERCEPTORS,
            useClass: AuthExpiredInterceptor,
            multi: true,
            deps: [
                Injector
            ]
        },
        {
            provide: HTTP_INTERCEPTORS,
            useClass: ErrorHandlerInterceptor,
            multi: true,
            deps: [
                EventManager
            ]
        },
        {
            provide: HTTP_INTERCEPTORS,
            useClass: NotificationInterceptor,
            multi: true,
            deps: [
                Injector
            ]
        },
        /*{
            provide: NgbDateParserFormatter,
            useFactory: () => { return new NgbDateMomentParserFormatter("DD-MM-YYYY") }
        }*/
    ],
    bootstrap: [ MainComponent ]
})
export class AppModule {}

我认为这是所有相关的,如果有人能解释什么是错的,遗漏了什么以及为什么,这将是非常有帮助的。同时,我将尝试在模块/导入系统上更好地记录我自己。

好的,基本上,您要导入ChartsComponent和ChartModule(我们这里讨论的是highcharts)的module.ts文件也需要导出ChartsComponent


导入这两者,然后在NgModule下导入ChartModule,并在declarations and exports标记ChartsComponent下导入。在destination data.module上导入ChartsComponent并将其标记在NgModule-entryComponents下。在目标DataComponent上导入ChartsComponent。

我们可以看到你的app.module.ts吗?在你的
charts.module.ts
中,不应该
从“/”导入{ChartsComponent}
be
import{ChartsComponent}from./charts.component'?哦!我刚刚添加了app.module.ts部分,但我会尝试一下蓝图chrisle me know me if you any luckUpdate:它不起作用。