Angular Interview Que Ans
Angular Interview Que Ans
2. What is TypeScript?
TypeScript is a typed superset of JavaScript created by Microsoft that adds optional
types, classes, async/await, and many other features, and compiles to plain
JavaScript. Angular built entirely in TypeScript and used as a primary language. You
can install it globally as
npm install -g typescript
Components directives
Structural directives
Attribute directives
Custom Directive
Structural Directives
Structural Directives are directives which change the structure of the DOM by adding
or removing elements. There are three built in structural directives, NgIf, NgFor and
NgSwitch.
Example: Structural Directives
<div *ngIf="user$ | async as user">
<span>Name: {{user.name}}</span>
<span>Age: {{user.age}}</span>
</div>
Attribute Directives
Attribute directives change the appearance or behavior of an element, component, or
another directive. ngClass, ngStyle are examples of attribute directives built-in to the
Angular framework.
Example: Attribute Directives
<p [ngStyle]="{'background': isBlue ? 'blue' : 'red'}"> I am an Attribute
Directive</p>
Components are the most basic UI building block of Angular Application which formed a tree
of angular components.