TCS
10+ SmartED Innovations Interview Questions and Answers
Q1. 1. How to share data from one component to another ?
Data can be shared between components using @Input, @Output, services, and state management libraries.
Use @Input to pass data from parent to child component
Use @Output to emit events from child to parent component
Use services to create a shared data source accessible by multiple components
Use state management libraries like NgRx or Redux to manage application state
Use route parameters to pass data between components via URL
Q2. 2. How does dependency injection work in Angular ?
Dependency injection is a design pattern used in Angular to provide dependencies to a component or service.
Dependencies are provided to a component or service through its constructor.
The Angular injector creates an instance of the dependency and passes it to the component or service.
Dependencies can be provided at different levels: module, component, or service.
The @Injectable decorator is used to mark a class as a service that can be injected.
The @Inject decorator is used to...read more
Q3. What is angular , why SPA came in picture
Angular is a JavaScript framework for building web applications. SPA came in picture for better user experience.
Angular is a client-side framework developed by Google.
It allows developers to build dynamic, single-page web applications.
SPA (Single Page Application) came in picture to provide a better user experience by reducing page reloads and improving performance.
SPA loads all the necessary resources (HTML, CSS, JS) at once and dynamically updates the content as the user in...read more
Q4. How do comunicate between 2 non relatable components
Using a shared service or event emitter to facilitate communication between non-relatable components.
Create a shared service with methods to send and receive data between components
Use event emitters to emit events and pass data between components
Utilize RxJS subjects to create an observable data stream for communication
Q5. Can variable be assigned to function
Yes, a variable can be assigned to a function.
Functions are first-class citizens in JavaScript and can be assigned to variables.
The variable will then reference the function and can be called as if it were the function itself.
Example: const myFunction = function() { console.log('Hello World!'); };
Example: const myVar = myFunction; myVar(); // logs 'Hello World!'
Q6. How dependency injection works in angular ?
Dependency injection in Angular allows for providing dependencies to a component or service from an external source.
Dependencies are provided at the module level using providers array in @NgModule decorator.
Dependencies can also be injected at the component level using constructor parameters.
Angular's injector resolves dependencies by looking up the provider token in the injector hierarchy.
Dependency injection helps in creating loosely coupled components and services.
Example:...read more
Q7. How to do partial reloading in angular ?
Partial reloading in Angular can be achieved by using the Angular Router to reload only specific parts of the page without refreshing the entire page.
Use Angular Router to navigate to the same component with different parameters to trigger a partial reload
Use router events like NavigationStart to detect when a route change is happening and perform partial reloading accordingly
Use Angular's ChangeDetectionStrategy.OnPush to optimize performance by only updating components when...read more
Q8. What is directives?what is what
Directives are markers on a DOM element that tell AngularJS to attach a specified behavior to that DOM element.
Directives are used to create reusable components.
They can be used to manipulate the DOM.
They can be used to add behavior to an existing DOM element.
They can be used to create custom attributes.
Examples include ng-repeat, ng-show, and ng-hide.
Q9. What is the purpose of ng-container
ng-container is a structural directive in Angular used for grouping elements without adding an extra element to the DOM.
Used to group elements together without adding an extra element to the DOM
Does not render any extra HTML element
Helps in organizing code and improving readability
Useful when applying structural directives like *ngIf or *ngFor
Q10. Lazy loading and how do achieve this
Lazy loading is a technique used to load only the necessary resources for a specific part of a web application when it is needed.
Lazy loading can be achieved in Angular by using the loadChildren property in the route configuration.
This property allows you to specify a separate module that will be loaded only when the route is activated.
Lazy loading helps improve the initial loading time of the application by loading modules on demand rather than all at once.
Q11. What is decorator in angular????
Decorators are functions that modify classes, methods, or properties at design time.
Decorators are used in Angular to add metadata to classes, methods, and properties.
They are denoted by the @ symbol and placed immediately before the item being decorated.
Examples include @Component, @Injectable, and @Input.
Decorators can be used to provide additional functionality or configuration to Angular components.
Q12. What is an arrow function
An arrow function is a concise way to write a function in JavaScript.
Uses the '=>' syntax
Does not have its own 'this' keyword
Cannot be used as a constructor
Can be used as a callback function
Q13. What is rxjs and its type
RxJS is a library for reactive programming using Observables, allowing for easier handling of asynchronous data streams.
RxJS stands for Reactive Extensions for JavaScript
It provides a way to work with asynchronous data streams
Operators like map, filter, and mergeMap can be used to manipulate and combine streams
Subscriptions are used to listen for values emitted by Observables
Q14. What is angular life cycle
Angular life cycle refers to the series of events that occur from the creation of a component to its destruction.
Angular components go through various stages like creation, rendering, updating, and destruction.
Some key life cycle hooks include ngOnInit, ngOnChanges, ngDoCheck, ngOnDestroy, etc.
Developers can use these hooks to perform tasks like initializing data, reacting to changes, and cleaning up resources.
Q15. Life cycle hooks in angular
Angular life cycle hooks are methods that get called at specific stages of a component's life cycle.
ngOnInit() - called after the component is initialized
ngOnChanges() - called when the component's input properties change
ngDoCheck() - called during every change detection cycle
ngAfterViewInit() - called after the component's view has been initialized
ngOnDestroy() - called just before the component is destroyed
More about working at TCS
Interview Process at SmartED Innovations
Top Angular Frontend Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month