I am developing an angular 4 app and I have two modules, the first module encapsulate some features that I need to use in others modules. For example I have the first module called SRModule I have imported SrCrComponent component:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
// module imports
import { SrCrComponent} from './sr-cr';
@NgModule({
imports: [
CommonModule
],
exports: [
SrCrComponent
],
declarations: [
SrCrComponent
]
})
export class SRModule {}
I want to use SrCrComponent in other component of another module, but I can get figure out how to use.
In my second module called ReportsModule, I have imported SRModule on it
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { CPComponent } from './cp/cp.component';
import { SRModule } from "../sr-module/sr.module";
@NgModule({
imports: [
CommonModule,
SRModule
],
declarations: [
CPComponent
]
})
export class ReportsModule { }
My question here is, how to use SrCrComponent component declared inside CPComponent on ReportsModule?
This is my CPComponent ts file:
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-chart-period',
templateUrl: './chart-period.component.html',
styleUrls: ['./chart-period.component.css']
})
export class CPComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
In my html of CPComponent I have a sr-gg component but not work,
<h2> Bar Chart</h2>
<sr-gg></sr-gg>
Oviously 'sr-g' is not a known element
in ReportsModule, in fac, this is the error that console is showed me, but I don't know where I need to declare or it should be inherit when I import SrCrComponen.