0 votes
in Angular by
Angular f5 tmsh commands cheat sheet

1 Answer

0 votes
by
Angular CLI Cheat Sheet: The best Commands to boost your productivity

Setting up a new project and creating all these files for every new component can take a lot of time.

It is tedious work that takes a lot of fun from the development process.

Fortunately, there are tools like the angular-cli, that can do all that hard work for you!

In this tutorial, we are going to take a look at the angular-cli and how to use it properly.

We will discover all the different things the CLI can do for you: Creating new angular projects, generating components or services or hosting your application.

At the end you will get a cheat sheet so you can quickly look up what you might have forgotten at any time!

Let's get started!

angular-build-banner

Setup

To use the angular-cli, we need to install it first.

Installing the angular-cli is quite easy. All you need to do, is to paste the following command into a terminal window.

npm install @angular/cli -g

For this to work, you need to have node.js with npm installed on your machine.

The installation may take a while.

angular-new-banner

Create your first Angular CLI app

Now it's time to create your first angular app with the CLI (Command Line Interface)

Doing so is not complex at all.

All you need to do, is choose a file-directory for your application to live in. Once that's done, open a terminal at that location and use the command

ng new [project-name]

to generate a new project. Make sure to replace [project-name] with a actual project name of your choice.

The CLI will now go ahead and create a new directory named just like the project.

Inside of that folder, it will create all the files for a basic but already executable angular application.

It will also install all required external dependencies. This can actually take some time.

angular-school-banner

ng new: Generate new angular projects

The command we used above is not the only way to create a new angular application.

In fact, the command itself as a ton of options, that are all controlled via additional flags.

Of course, you do not need to know all of them by heart, but some of them are pretty useful.

Here are some of them:

--dry-run: Try things out

Sometimes you want to try out, what a command does, before it actually does something.

Specifically if you are new to the CLI, the dry-run option will be very useful.

This option will stop the CLI from making any changes to the file system. Instead it will print everything it would have done to the console. That way you can check if the command actually does what you thought it does, before it causes any harm.

For example, the option could be used like this:

ng new example --dry-run

Related questions

0 votes
0 votes
asked Aug 11, 2023 in Angular by DavidAnderson
0 votes
asked Aug 11, 2023 in Angular by DavidAnderson
...