Category Archives: 1.05-Angular

Objects in TypeScript

We already created our class. But there is a problem. We can’t directly use any class. For example we have a class called Point as follows- class Point{ x:number; y:number; draw(){ //————– } getDistance(another:Point){ //————– } } Here we have two variables x and y and two methods draw() and getDistance(). If we want to… Read More »

Class in TypeScript

Class is the template of object that describe the state and behavior of an object. Class enables us to implement the Cohesion principles which means that group of related objects should be placed together. Similarly the Class groups together Variables (properties) and Functions (methods) those are highly related. Example: class Point{     x:number;     y:number;… Read More »

Arrow function in TypeScript

To build Angular Application using TypeScript we need to know about Arrow function. In JavaScript we can declare a function like follows- let log = function(message){     console.log(message); } In TypeScript there is a shorter way to define this function as follows- let dolLog = (message)=>{     console.log(message); } Here we didn’t used function keyword… Read More »

Type Assertion in TypeScript

Now we will discuss about Type Assertions in TypeScript.  Let’s declare a variable and assign string value to it as follows- let message = ‘abc’; Then we type follows- Here as soon as we typed ‘.’ after message it shows intellisense. Here all the item with purple icons are function. We select endsWith function as… Read More »

Data Types & Declaring Variables in TypeScript

Now we will discuss about different types we have in TypeScript. In TypeScript we can declare variable either by using let keyword or var keyword as follows- let variableName = variableValue; var variableName = variableValue; The variable type become as per the type of the value of the variable let numberVariable = 8; As we… Read More »

Declaring Variables in TypeScript

Now we’ll declare how we can declare variables in TypeScript. In TypeScript there are two ways to declare variables. One ways is as JavaScript by using var keyword as follows- var number = 1; We can also use the let keyword as follows- let count = 2; let keyword also been added to JavaScript. JavaScript has few different… Read More »

Installation of TypeScript

Now we will see how to install TypeScript. Open VS-Code then Go to Terminal (View -> Integrated Terminal) and write following command- Here “npm” stands for “node package manager” and “g” stands for “global” Typescript will install successfully- Our installed version is 3.0.3 [as shown last line of above screen shot] Now type “tsc –version”… Read More »

What is TypeScript

TypeScript is a superset of JavaScript which means any valid JavaScript code is also valid TypeScript code. TypeScript also has some additional features that do not exist in the current version of JavaScript but supported by most browsers.  Some of those features are- Strong Typing In TypeScript we have the concept of Strong Typing.  Languages… Read More »

Introduction To TypeScript Fundamentals

In order to build applications with Angular we need to be comfortable with TypeScript. So now we will discuss about the fundamentals of TypeScript as well as Object Oriented Programming Principles. So by the end of this series of tutorials we will have a good understanding of Type annotations Arrow functions Interfaces Classes Constructors Access… Read More »


Now we will make tiny change inside our Angular Application. Go to src/app folder. Open App.Component.ts.  Inside the file our code is as follows- import { Component } from ‘@angular/core’;  @Component({   selector: ‘app-root’,   templateUrl: ‘./app.component.html’,   styleUrls: [‘./app.component.css’] }) export class AppComponent {   title = ‘HelloWorld’; } If yet not run the… Read More »