Angular Intro

Pankaj Parkar

Software Engineer

@TSS Consultancy

  • Microsoft MVP (Visual Studio & Technology)
  • Community Contributor
  • Loves to Code at .Net and Angular

What you should know?

  • Html
  • CSS Basics
  • Javascript Basics
  • Programming Fundamentals

What is Angular?

  • Client Side / Framework
  • Developed and maintained by Google
  • Used to craft powerful Single Page Applications (SPA's)
  • Part of MEAN Stack
  • Provides modularize way to write code

What Angular is not?

  • A Server side Framework
  • Library like JQuery, React, etc
  • Design Patterns
  • Another new OOP language like C# or Java
  • Extension or Plugin

Angular Version History

AngularJS / Angular 1  around 2009

Angular 2 on Sept 2017

Angular 3  skipped

Angular 4 on April 2017

Angular 5 on Nov 2017

Angular X after each six month

Angular Terminology

Angular 1.x = AngularJS  

Angular 2+ = Angular     

WhY Use Angular?

  • Rapid Development, Code Generation and Better tooling
  • Component Architecture
  • Dynamic Content
  • Two way data bindings
  • Cross Platform
  • Unit Testing Ready
  • 5x faster than AngularJS
  • Server Side Rendering

What IS Typescript?

  • Superset of Javascript with next Javascript feature enabled
  • Static typing optional
  • Class based Object oriented programming, you can use classes, interface, enum, etc.
//`myVariable` holds string value
let myVariable: string = 'Something';
//typescript will throw at compile time error
myVariable = 1;
let myBoolean: bool = true;

Core Features

Component Data Bindings Directives
Services Templating Pipes
Routing Http Modules Events
Testing Observable Animation
Build Tool Form Modules Typescript


  • Basic building block of an Angular app
  • Extends html vocabulary
  • It helps to create less fault tolerant application

@Component({ metadata })

import { Component } from '@angular/core';

   selector: 'my-app', 
   template: `<h1>
               Hello, {{name}}
   styles: [`.body{ margin: auto;}`]
export class GreetComopnent {
  name: string = 'World';


@Directive({ metadata })

import { 
  Directive, HostListner
} from '@angular/core';

  selector: '[myDirective],.myDirective',
export class MyDirective {
  @HostListner('click', ['$event'])
  onClick(event: any) {
<div myDirective>
  Click Me
<div class=".myDirective">
  Click Me
  • Directive is used to attach some specific behaviour onto DOM
  • Directive is template less Component


import { Injectable } from '@angular/core';
import { Http } from '@angular/http';

@Injectable() // required for dependency injection to work
export class PostService{
  constructor(private http: Http){

    return this.http.get('')
      .map(res => res.json());


  • Helps to extract common code to generic place.
  • Used to share data in different parts of application.
  • Good to place to make an API calls and expose those method from service


@Pipe({ metadata })

@Pipe({ name: 'isNumber' })
export class IsNumberPipe implements PipeTransform {
  transform(n: any) {
    return !isNaN(parseFloat(n)) 
           && isFinite(n);
  {{'Test' | isNumber }}  //Output: false
  {{ 1234  | isNumber }}  //Output: true

Value transformation for display purpose

  {{today | date: 'shortDate'}}  //Ouput: '10-10-2017'

Create Custom Pipe

Angular Module

  • Help organize an application into cohesive blocks of functionality.

@NgModule({ metadata })

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent }  from './app.component';

  imports:      [ BrowserModule ], //other modules or sub-modules
  declarations: [ AppComponent ], //components, directives, pipes
  bootstrap:    [ AppComponent ] //bootstrap component
  exports:      [] //it can have module,directive,component,pipe,service
export class AppModule { }












  • There must be one root component with its main AppModule

Bootstrap root component

How to use Angular?

Three ways to create an Angular App

  1. Build from Scratch
  2. Angular QuickStart
  3. Angular CLI (recommended)


  • Code Editor: Visual Studio Code, Atom, Sublime, etc.
  • Node & npm 
  • Typescript


Docs (For API import check)

Best Practices

Coding guidelines by John Papa



Thank you


Q & A

Introduction to Angular

By Pankaj Parkar

Introduction to Angular

Angular Introduction

  • 877