Creating our first Angular project

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
Search for a command to run...

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
Angular hero tour is the best Hand-on made by Angular to learn about how to use Lambda
The tour of heroes is very good, it misses some deep-dive stuff though. Also not sure why Lambda is in here?
because it's morning, and I was thinking one thing and I wrote another one Chris Bongers
I was meaning Components services and Guards.
I think as you said, the missing part is a deep-dive tour. :)
Most of you know me for my consistency, a golden arrow in my blog series. I've written 1000 articles in 1008 days! Almost an article a day, and my honeymoon was the only holiday I ever took. I'm super proud of this achievement; it has been a fantasti...

It's not the first time I'll be talking about community. I think it's an essential aspect of any successful tool. This shows in my previous explorations of Astro, Medusa, and now Vendure as well. All these products thrive in a super open, welcoming, ...

The cool part about Vendure is how easy it is to set up and how abstract each layer is. Basically, we get the following elements: External database Server Worker Admin UI Frontend While this is amazing, it also brings a bit of complexity when it co...

The previous article looked at customizing Vendure on a data and process level. In this article, we'll look at customizing emails, as they are often a big part of a webshop system. We'll be looking at two different layers of customization for customi...

Even though Vendure is a pretty significant project out of the box, in some cases, we might want to go in and modify some elements to work to our specific use case. In this article, I'll take a high-level look at some elements we can customize within...

Over time I did quite a few first of applications like Ionic and React.
Today we'll be looking at starting our first Angular project.
We will be creating a very basic application that looks like this:

Angular is a framework that can be used to create single-page applications. It can also be used in mobile applications like Ionic.
Angular is a component-driven framework like we see in React as well.
It's written in Typescript, making our lives easier and using HTML as it's main frontend.
To get started, we first need to set-up the Angular CLI (Command Line Interface). This is a tool we can run in our terminal and can be used to generate certain components for us.
Open your favourite terminal (iTerm2 is mine) and run the following command.
npm install -g @angular/cli
Now that we have our Angular CLI installed, we can verify it works by running the following command.
ng v
We should then see a response close to this. (Versions may differ)

Once we have the Angular CLI installed, we can use the following command to generate our first app.
ng new angular-app
This will ask you if you want to use Routing and which stylesheet pre-processor you want to use.
I choose Yes for Routing and SCSS for the stylesheet.
Now we can navigate to our application and run the ng serve command to start our app up.
cd angular-app
ng serve
We can then open a browser at localhost:4200 and see our first application.

As mentioned, Angular a component-based framework, so let's add a new component.
We can use the Angular CLI to generate this for us.
ng generate component welcome
This will generate our welcome component, but we won't be able to do anything with it just yet.
Let's first add a new route for this component.
Open your editor and find the following file: src/app/app-routing.module.ts.
Add the import for the welcome component up top and change the routes.
import { WelcomeComponent } from './welcome/welcome.component';
const routes: Routes = [
{ path: 'welcome', component: WelcomeComponent }
];
Now let's edit our app.component.html to look like this.
<h1>Our first angular app</h1>
<nav>
<ul>
<li><a routerLink="/" routerLinkActive="active">Empty homepage</a></li>
<li><a routerLink="/welcome" routerLinkActive="active">Welcome</a></li>
</ul>
</nav>
<router-outlet></router-outlet>
Here we create our navigation which will link to the homepage which is empty and the welcome page.
Then at the bottom, we have our router-outlet, which will actually show the router output.
This will result in the following.

There we go, we created our basic Angular app and added a custom component where we can route to.
From here, we can build many more pages and created a fully functional website!
You can find more information on the Angular website or download this project from GitHub.
Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter