DEV Community

Gabriela Diniz
Gabriela Diniz

Posted on

The basic commands in Angular

Basic commands to initialize your project in Angular:

  • To create a new project, open your terminal and execute:
ng new project-name
Enter fullscreen mode Exit fullscreen mode
  • To execute your application and create the server project, execute the following commands:
ng serve
Enter fullscreen mode Exit fullscreen mode
  • Create a component:
ng g c /folder-name/component-name
Enter fullscreen mode Exit fullscreen mode
  • Create a module:
ng g m /folder-name/component-name
Enter fullscreen mode Exit fullscreen mode
  • Create an interface:
ng g interface /folder-name/interface-name
Enter fullscreen mode Exit fullscreen mode
  • Create a service:
ng g s /folder-service/service-name
Enter fullscreen mode Exit fullscreen mode
  • Install CLI:
npm i -g @angular/cli
Enter fullscreen mode Exit fullscreen mode

If you want to deploy your Angular project locally or on GitPages, for example, execute:

ng build
Enter fullscreen mode Exit fullscreen mode

This command allows you to generate a "bundle" of the entire project, in the format of HTML + Javascript + CSS files, to be published on any static server.


Observations:

  • Services are not automatically imported into app.module.ts (unlike components).
  • :host {} in the SCSS file modifies only that specific file.

Top comments (0)