diff --git a/packages/angular-cli/blueprints/module/index.js b/packages/angular-cli/blueprints/module/index.js index 3cd3b5646119..846d4758a9dc 100644 --- a/packages/angular-cli/blueprints/module/index.js +++ b/packages/angular-cli/blueprints/module/index.js @@ -58,8 +58,12 @@ module.exports = { }, afterInstall: function (options) { - options.entity.name = path.relative(this.dynamicPath.appRoot, this.generatePath); - options.flat = false; + // Note that `this.generatePath` already contains `this.dasherizedModuleName` + // So, the path will end like `name/name`, + // which is correct for `name.component.ts` created in module `name` + const componentPath = path.join(this.generatePath, this.dasherizedModuleName); + options.entity.name = path.relative(this.dynamicPath.appRoot, componentPath); + options.flat = true; options.route = false; options.inlineTemplate = false; options.inlineStyle = false;