CLI

The Angular CLI

[R] https://github.com/angular/angular-cli/wiki

a command line interface tool that can create a project, add files, and perform a variety of ongoing development tasks such as testing, bundling, and deployment.

Generate a new project and skeleton application

ng new my-app --routing
cd my-app
ng serve --open

The ng serve command launches the server, watches your files, and rebuilds the app as you make changes to those files.

the --open (or just -o) option will automatically open your browser on http://localhost:4200/.

ng generate

Component

ng generate component <component_name>
ng g c <component_name>

ng generate component module_name/heroes --spec=false (no spec file)
ng generate component heroes -it  (inline template)

Service

There are several ways to provide the HeroService: in the HeroesComponent, in the AppComponent, in the AppModule. Each option has pros and cons.

Module

--flat puts the file in src/app instead of its own folder. --module=app tells the CLI to register it in the imports array of the AppModule.

Directives

Last updated

Was this helpful?