All Angular CLI Commands ,2024

Angular CLI is a command-line interface tool that helps to initialize, develop, scaffold, and maintain the applications of Angular Project. You can use the Angular CLI command directly on the command shell. These are the following Angular CLI cmd used to develop Angular Project.

I have provided mostly use the command in your Angular 13 app. these are the following given.

  • ng version command
  • ng new command
  • ng build or ng b command
  • ng g command
  • ng g component command
  • ng g pipe command
  • ng g directive command
  • ng g module command
  • ng g interface command
  • ng g service command
  • ng add command

1). ng version command

ng version

ng version command is used to check the angular version installed in your machine.

2). ng new <ProjectName> command

ng new ProjectName used to create new angular project application.For example you want to create your new angular project name angular12Tutorial then we will use following command.

ng new angular12Tutorial

3).ng build command or ng b command

The ng build command is used to compile an Angular 13 application into an output directory named dist/ at the given output path. It will be must execute form within your workspace directory.

 ng build <project> [options]

 ng b <project> [options]

4). ng g commond

Generates and/or modifies files based on a schematic.
usage: ng generate [options]

	arguments:
		  schematic
		    The schematic or collection:schematic to generate.

		options:
		  --defaults
		    Disable interactive input prompts for options with a default.
		  --dry-run (-d)
		    Run through and reports activity without writing out results.
		  --force (-f)
		    Force overwriting of existing files.
		  --help
		    Shows a help message for this command in the console.
		  --interactive
		    Enable interactive input prompts.

		Available Schematics:
		  Collection "@schematics/angular" (default):
		    app-shell
		    application
		    class
		    component
		    directive
		    enum
		    guard
		    interceptor
		    interface
		    library
		    module
		    pipe
		    resolver
		    service
		    service-worker
		    web-worker

5). ng g c <componentName>

use ng g c componentName to create new component .

ng g c <componentName>

for example we want to use to create header component then we will using following command

ng g c header

if we need to create inside folder the we will use following command

 ng g c folderName/componentName

6). ng g pipe Command

ng g pipe command use to create pipe in angular 13.The command of used to create new pipe in angular 13

  ng g pipe <pipename>

for example we need to create PriceFormate pipe the we will use following command.

ng g pipe PriceFormate

7). ng g directive command

ng g directive use to create the directory in angular 13 projects.the syntax has been given bellow

ng g directive <directive-name>

for example, we need to create a new directive cssDirective then we will use the following command

ng g directive cssDirective

8). ng g module command

ng g module command is used to create a new module inside the Angular 13 project. for example, we need to create Authmodule then we will use the following command

ng g module AuthModule

9). ng g interface command

ng g interface use to create interface inside angular 13 project. For example, we need to create AuthInterface then we will use following command

ng g interface AuthInterface 

10). ng g service Command

ng g service command use to create new services inside in your Angular 13 application. for example, we need to create new LoginUser Service then we will use following command.

ng g service LoginUser

11). ng add <commandName>

ng add Command used to create your own command inside Angular 13 Application.

Discover more from STRUGGLER KING.COM

Subscribe now to keep reading and get access to the full archive.

Continue Reading