Angular CLI Commands

Dry Run argument :

Dry run argument is the most important argument of all in Angular CLI command

ng new DryRunDemo --dry-run
ng g m demo --dry-run --flat
$ node –v
(to check the version of node)

$ npm install –g @angular/cli
(to install the Angular CLI globally on our machine)

$ ng –v
(to verify the version of Angular CLI)

$ ng new FirstApp
(to generate a new app of name FirstApp)

$ ng new FirstApp –-dry-run
(this command will only report the files and not write them)

$ ng new FirstApp –-skip-install
(this command will generate a new app without running the npm install)

$ ng new –-help
$ ng new -h
(will list out all the flags associated with the ng new command)

$ ng new FirstApp –-style scss
(will be using sass instead of css in the generated app)

$ ng new FirstApp –-prefix YourName
(will set the default selector as YourName)

$ ng new FirstApp –-skip-test
(will not generate the spec files while creating the app)

$ ng new FirstApp –-routing
(will generate a new app with a default routing module)

$ ng new FirstApp –-routing –-style scss –-prefix YourName
(example of the above flags in a command combined)

$ ng lint
(will do the linting of the TypeScript code)

$ ng lint –-help
(will list out all the options available with the lint command)

$ ng lint –-format stylish
(will lint and format the output in a coloured manner)

$ ng lint –-fix
(will lint and fix all the problems if any)

$ ng generate component User
$ ng g c User
(g --> alias for generate, c --> alias for component)
(will create user.component.ts)

$ ng g c star –-flat
(Will not create a /star folder)

$ ng g c star --inline-template --inline-style 
$ ng g c star –it –is
(Will not create template/html and css file, it will be inline in ts file)

$ng g c star --spec false
(Will not create a spec file)

$ ng g c star --prefix pj
(Prefix the component with pj-)

$ ng generate service user-data
$ ng g s user-data
(will create user-data.service.ts)

$ ng generate class user-model
$ ng g c user-model
(will create user-model.ts)

$ ng g module admin
$ ng g m admin 
(It will create admin.module.ts)

$ ng g m sales --routing
(It will create sales.module.ts and sales-routing.module.ts)

$ ng serve --poll=2000
(If your server is not detecting the changes you call fire this command to increase the polling capacity of server)

$ ng serve -o
(opens the hyperlink in browser after compilation in successfull)

Leave a Comment