1. Explains different types of directives with example?
There are mainly three types of angular directives. They are:
- Component directive: It is used to specify HTML templates. Example: @component
- Attribute directive: It is used to change or modify the behavior of the HTML element. Example: ngModel
- Structural directive: It is used to add or remove the HTML element in DOM layout. Example: ngIf
2. What is refactoring?
Refactoring is a technique for changing the name of file and folder and reflect that change all over the project structure without changing the underlying functionality.
3. Explain ng generate?
ng generate is a command which is used to generate components, services, module etc.
Let us consider, we generate a component by using following syntax:
ng generate component component-name
OR
ng g c component-name
4. What is dependency injection?
Dependency injection or DI is a technique in which a class requests dependencies from external sources rather than creating itself.
5. How to navigate from within the component code?
we can navigate from the component code as:
6. What is a constructor in a class?
Constructor is a special kind of function which has no return type and has the same name as a class but in the case of TypeScript constructor keyword is enough. The main functionality of the constructor is to instantiate the object of the class.
7. What is the syntax of ngFor loop?
ngFor is a structural directive that has ability of changing the DOM layout by adding or removing DOM element.
syntax:
video tutorial for angular:


