Author -  Sai gowtham

Angular 8 intro tutorial for the beginners

In this tutorial, we are going to learn about how to create our first angular project by using angular cli.

What is Angular?

Angular is a frontend JavaScript framework which helps us to create a single page apps.

  • Angular is a complete rewrite of angularjs.

Single page app

The single page app means we only have a single HTML page which is reusing throughout our app instead of downloading new page everytime from the server.

When Angular is released ?

  • Angular is relased on 14 September 2016.

Why Angular so called as Angular 2,3,4,5,6?

  • Angular is a complete rewrite of angularjs which leads to confusion among in developers.
  • AngularJS refers to the version 1.x without JS refer to version Angular 2 and up.

Later they released angular 4,5,6 versions with new features like progressive web apps support, http client, etc and the team skipped angular 3.

Advantages of Using Angular

  • Strong type system.
  • Good tooling infrastructure.
  • Simple and declarative templates.
  • You can also build native mobile apps using Ionic, Cordova and also desktop based apps.

Who uses Angular

  1. Google express
  2. Code.gov
  3. Udacity
  4. Udemy

Many more companies uses angular in production.

Getting started

Let’s create our first angular project by using angular-cli.

Angular cli is a command line tool which helps us to create a new angular projects (it follows the best practices).

Requirements

  • Nodejs(v10) is required to install the angular cli.

Open your terminal or cmd and run the following command to install the angular cli in your pc.

npm install -g @angular/cli

If you are using mac then add sudo in front of the npm.

angular-cli

Creating a project

Once you successfully installed angular cli, let’s create a project now.

Open your terminal and run the below command.

ng new my-angular-app

my-angular-cli-app

This above command will download the angular related files in my-angular-app folder.

Note if your prompt with any questions then type N to choose no.

Let’s change our current working directory.

cd my-angular-app

Running Development server

Let’s run the development server by using the below command.

ng serve

Now open your browser and navigate to localhost:4200 to see your angular app.

angular-app-dev-server

Folder Structure

Let’s open a my-angular-app folder in your favorite code editor and navigate to src because its the place where our app lives. Don’t worry about remaining files.

Inside src you will see the app folder which contains four files listed below.

- app.component.html
- app.component.css
- app.component.ts
- app.module.ts

app.component.html: It contains the HTML markup.

app.component.css. It contains CSS related code.

app.component.ts: It contains JavaScript/TypeScript realted code.

app.modules.ts: It also called root app module in angular where we import and declare the other modules, components so that angular has aware of that other components and modules because angular first runs the app.module.ts.

Now navigate to app.component.html and remove everything then add the below markup.

app.component.html
<h1>Hello angular</h1>

Now your app reloads with the updated markup.

Interpolation

We need to use the double curly brace syntax {{}} to interpolate the data in angular.

Open your app.component.ts and update with below code.

app.component.ts
import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
   name = 'Angular 8';}

In the above code, we have declared new variable called name ,let’s interpolate the name in our app.component.html

app.component.html
  <!-- interpolation -->
<h1>Hello {{name}}</h1>

angular interpolation example

Have seen in above image Hello Angular 8 where Angular 8 comes from name="Angular 8" which we declared inside app.component.ts.

We can also use JavaScript methods inside interpolation syntax.

app.component.html
  <!-- interpolation -->
<h1>Hello {{name.toLowerCase()}}</h1>

1.Angular components tutorial

2.Angular attribute binding

3.Event handling in angular

Css Tutorials & Demos

How rotate an image continuously in CSS

In this demo, we are going to learn about how to rotate an image continuously using the css animations.

How to create a Instagram login Page

In this demo, i will show you how to create a instagram login page using html and css.

How to create a pulse animation in CSS

In this demo, i will show you how to create a pulse animation using css.

Creating a snowfall animation using css and JavaScript

In this demo, i will show you how to create a snow fall animation using css and JavaScript.

Top Udemy Courses

JavaScript - The Complete Guide 2023 (Beginner + Advanced)
JavaScript - The Complete Guide 2023 (Beginner + Advanced)
116,648 students enrolled
52 hours of video content
$14.99 FROM UDEMY
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
631,582 students enrolled
49 hours of video content
$24.99 FROM UDEMY
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
203,937 students enrolled
31.5 hours of video content
$14.99 FROM UDEMY