Commands in Angular CLI: Una lista de los comandos más usados durante la implementación.

Here a common commands used working with Angular 2

You can download the PDF format in SpeakerDeck Commons Commands Angular CLI

Generating new projects


Generate a new app in /my-app:
ng new my-app


Don’t write the files, but report them:
ng new my-app --dry-run


Generate without running npm install:
ng new my-app --skip-install


Generate projects with routing class include, however you need to add the new components into routing manually:
ng new [project's name] --ng4 --routing


Style should use SASS:
ng new my-app --style sass


Set the default selector prefix:
ng new my-app --prefix ma


Don’t add the project to git:
ng new my-app --skip-git


Don’t generate specs files:
ng new my-app --skip-tests

Add a default routing module:
ng new my-app --routing


Generating components


ng g c [component's name]


Generating directives

ng  g d [directive's name]


Generate directive in your own folder:
ng  g d [directive's name] --flat false


Generating services


ng g s [service’s name]

Include the provider service into app.module class.
ng g s [service’s name] -m app.module


Generating classes


ng g cl [class’s name]


Generating interfaces


ng g i [interface’s name]


Generating enums

ng g e [enum’s name]


Generating pipes

ng g p [pipe’s name]


Linting


Lint the typescript code:
ng lint

Show the help for linting:
ng lint --help

Lint and format the output:
ng lint --format stylish

Lint and attempt to fix all problems:
ng lint --fix


Generating modules


Generate admin.module.ts:
ng g module [module’s name]

Generate admin.module.ts and admin-routing.module.ts:
ng g module [module’s name] --routing

Generate new component in [module’s name]:
ng g c [module’s name]/ [component’s name]


Generate new component in [module’s name]:
ng g c [component’s name] -m [module’s directory/module’s name]


Generating guards


CanActive guard auth.guard.ts:
ng g guard auth


Common commands


Don’t create a /my-component folder:
ng g c my-component --flat

Put the template in the .ts file:
ng g c my-component --inline-template


Put the style in the .ts file:
ng g c my-component --inline-style

Prefix the component with my:
ng g c my-component --prefix my

Don’t create a spec file:
ng g c my-component --spec false


Build commands


ng build

Output prod build files:
ng build --prod

Serving commands

Serve a dev build in memory:
ng serve

ng serve -o

ng serve -p 8626 -o -lr false


Testing commands

Run tests, re-run when files changes:
ng test

Equivalents, under the covers:
ng test -sr

Equivalents, under the covers:
ng test -w false

Generate the code coverage report:

ng test --code-coverage


You can download the PDF format in SpeakerDeck Commons Commands Angular CLI


Previous
Next Post »
Thanks for your comment