Category: Angular Interview Questions
-
What type of DOM does Angular implement?
DOM (Document Object Model) treats an XML or HTML document as a tree structure in which each node is an object representing a part of the document. Angular uses the regular DOM. This updates the entire tree structure of HTML tags until it reaches the data to be updated. However, to ensure that the speed…
-
What is Eager and Lazy loading?
Eager loading is the default module-loading strategy. Feature modules under Eager loading are loaded before the application starts. This is typically used for small size applications. Lazy loading dynamically loads the feature modules when there’s a demand. This makes the application faster. It is used for bigger applications where all the modules are not required…
-
What is Bootstrap? How is it embedded into Angular?
Bootstrap is a powerful toolkit. It is a collection of HTML, CSS, and JavaScript tools for creating and building responsive web pages and web applications. There are two ways to embed the bootstrap library into your application. npm install bootstrap npm install jquery
-
How to use ngFor in a tag?
The ngFor directive is used to build lists and tables in the HTML templates. In simple terms, this directive is used to iterate over an array or an object and create a template for each element. <ul> <li *ngFor = “let items in itemlist”> {{ item }} </li> </ul>
-
What is ngOnInit? How is it defined?
ngOnInit is a lifecycle hook and a callback method that is run by Angular to indicate that a component has been created. It takes no parameters and returns a void type. export class MyComponent implements OnInit { constructor() { } ngOnInit(): void { //…. } }
-
What are Promises and Observables in Angular?
While both the concepts deal with Asynchronous events in Angular, Promises handle one such event at a time while observables handle a sequence of events over some time. Promises – They emit a single value at a time. They execute immediately after creation and are not cancellable. They are Push errors to the child promises. …
-
What are Services in Angular?
Angular Services perform tasks that are used by multiple components. These tasks could be data and image fetching, network connections, and database management among others. They perform all the operational tasks for the components and avoid rewriting of code. A service can be written once and injected into all the components that use that service.
-
Explain the @Component Decorator.
TypeScript class is one that is used to create components. This genre of class is then decorated with the “@Component” decorator. The decorato’s purpose is to accept a metadata object that provides relevant information about the component. The image above shows an App component – a pure TypeScript class decorated with the “@Component” decorator. The…
-
What is the difference between AOT and JIT?
Ahead of Time (AOT) compilation converts your code during the build time before the browser downloads and runs that code. This ensures faster rendering to the browser. To specify AOT compilation, include the –aot option with the ng build or ng serve command. The Just-in-Time (JIT) compilation process is a way of compiling computer code…