feature request(ng g c): add option to include generated component in module exports list
Please consider add following feature option when generating a component:
With a option, say --add-to-exports, we can run ng g c parent/shall-be-exported --add-to-exports, and get shallBeExportedComponent in the exports list of parentModule.
I tried to give this a go but came across this:
blueprints/component/index.js
// ...
if(options.export) {
returns.push(
astUtils.addExportToModule(this.pathToModule, className, importPath)
.then(change => change.apply(NodeHost)));
}
ast-utils.ts
export function addExportToModule(modulePath: string, classifiedName: string,
importPath: string): Promise<Change> {
return _addSymbolToNgModuleMetadata(modulePath, 'exports', classifiedName, importPath);
}
generates:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { CompTestComponent } from './comp-test/comp-test.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule
],
providers: [],
bootstrap: [AppComponent],
exports: [CompTestComponent]
})
export class AppModule { }
As you can see CompTestComponent is being added to the exports list, but it's not being declared.
@baruchvlz thanks for taking a look, I'm about to start implementing this, I will keep you posted.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.