Sagar Ganesh
Sagar Ganesh

Reputation: 2584

How to remove prefix 'app' and create folder wise components/modules using angular-cli command?

I've installed latest version of node i.e 6.10 and angular-cli, I'm trying to create folder wise component and module, but not able to do this, when I execute the following command, it will create component/module but inside 'app/' folder:

ng generate module app.module/app.module

Event I tried to modify the prefix attribute in .angular-cli.json to blank as follows but still not working:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "app-cli"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "",
      "styles": [
        "styles.css"
      ],
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "project": "src/tsconfig.app.json"
    },
    {
      "project": "src/tsconfig.spec.json"
    },
    {
      "project": "e2e/tsconfig.e2e.json"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "component": {}
  }
}

Also I tried to remove the attribute itself, but it doesn't work. Please tell me how to create folder wise component using angular-cli command line? Here whats happening :

This is happening:

enter image description here

This structure I wanted:

enter image description here

Upvotes: 3

Views: 5285

Answers (2)

meo
meo

Reputation: 71

In angular.json - change the prefix value to spaces like so:

"prefix": "",

Upvotes: 5

Huy Doan
Huy Doan

Reputation: 21

Just remove some checks in tslint file, like below:

"component-selector": [
  true,
  "app",
  "element",
  "kebab-case"
]

Upvotes: 2

Related Questions