Creating a new app

In this section you will learn how to develop a brand new Angular application using Angular CLI., the command line interface for Angular.

In the following portion of code you can find the commands to execute into an Ubuntu 17.10 server.

# Installing Node.js.
# https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
sudo apt install curl
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs
# Installing Angular CLI.
# https://github.com/angular/angular-cli#installation
sudo npm install -g @angular/cli

Once done, the creation of a new Angular application can be completed using the following command.

ng new my-project

Into the brand new my-project folder you will find a ready-to-be-used project implementing a very basic Angular application.

Before considering as completed the task, let's edit the src/app/app.module.ts file and add the following source code.

...
import { RouterModule, Routes } from '@angular/router';
...
const appRoutes: Routes = [];
...
@NgModule({
  imports: [
    RouterModule.forRoot(appRoutes),

Now edit the src/app/app.component.html file and replace the entire content with the following one.

<p>
  <a href="/">Home</a>
</p>
<router-outlet></router-outlet>

To import and install all the dependencies, launch the npm install command from the root folder of the project.

To launch the application, run the npm start command and open a browser at http://localhost:4200. Below a screenshot showing some links in addiction to the home introduced above

results matching ""

    No results matching ""