instanceof is a type Guard, which checks if a value is an instance of a class or a constructor function. It also acts as a Type Guard, helping us the infer the type correctly in the scope
Union Types in Typescript allows a variable to have the ability to store a value of several types. We define union types by using a pipe- (|) to separate each of the possible types. Hence, number | string | boolean is the type of a variable, which can have the value that can be a number, a string, or a boolean.
TypeScript Literal Types restrict the value of a variable to finite valid values. The latest version of Typescript supports the following Literal Types. String Literal Types,Numeric Literal Types,Boolean Literal Types & Enum Literal Types. This is very useful feature which restrict the possible values, that you can store in a variable
In this tutorial, we will show you how to create a Custom Directive in Angular. The Angular directives help us to extend or manipulate the DOM. We can change the appearance, behavior, or layout of a DOM element using the directives. We will build a four directive example s and show you how to Create a custom directive using the
@Directive decorator. We will create both custom attribute directive & custom Structural directive. How to setup selectors. Pass value to it using the @input. How to respond to user inputs, Manipulate the DOM element (Change the Appearance) etc.
Angular Track by option improves the Performance of the ngFor if the collection has a large no of items and keeps changing. Learn why we need it and how to use it to improve the performance of the ngFor.