- Ask js questions - Ask about css & bootstrap - custom components - knowledge about google maps - knowledge of ng bootstrap - knowledge about cdci - knowledge about micro services - knowledge of docker - diff between json and xml - what is agail methodology - knowledge of strip - how many type of element s there in strip - diff between ssr and csr - what are signals - how can we reduce load of DB of API call - Communication: 2.5/5 - Angular experince: 5.5 years - NodeJS experince: 5.5 years - Worked with AngularJS: No - Angular SSR: No - Custom components: No - knowledge about cdci: No - knowledge of docker: Yes - knowledge of MQTT: No - what is agail methodology: - knowledge of strip: No - Angular 16: Not aware with new feature - Bootstrap: 2.5/5 - ngrx store: No ## Interview Questions https://www.simplilearn.com/tutorials/angular-tutorial/angular-interview-questions - How Angular application start Main.ts is main Entry point of angular compiler, When we fire Command ng serve , the execution comes to main.ts file. and there angular bootstrap or loads default app.module.ts. Then in app.module.ts we bootstrap app.component using bootstrap : [AppComponent] in @NgModule. - What is Ajax - AJAX stands for Asynchronous JavaScript and XML. It is a set of web development techniques that uses various web technologies on the client-side to create asynchronous web applications - ngxs store - Store: The store is a global state manager that dispatches actions your state containers listen to and provides a way to select data slices out from the global state. - Action: Actions can either be thought of as a command which should trigger something to happen, or as the resulting event of something that has already happened. - State: States are classes along with decorators to describe metadata and action mappings. To define a state container, let's create an ES2015 class and decorate it with the State decorator. - Diff between library & framework - Both the framework vs library is precoded support programs to develop complex software applications. - A library is a collection of prewritten code that can be used to simplify tasks. - library: JQuery , React JS - A framework is like a foundation for developers to build applications for a particular platform. - A framework provides tools which can be use directly to make easy development - framework: AngularJS , Spring , NodeJS - What is DOM - document object model - When a web page is loaded, the browser creates a Document Object Model of the page. - A DOM element is something like a DIV, HTML, BODY element on a page. You can add classes to all and add style with respect to added classes using CSS, or interact with them using JS - Types of auth guard - CanActivate, CanActivateChild, CanDeactivate, Resolve and CanLoad - Directives - Angular 8 directives are DOM elements to interact with your application. Generally, directive is a TypeScript function. - Attribute directives - Attribute directives deal with changing the look and behavior of the dom element. You can create your own directives as shown below. - custom directive with style like tooltip ngstyle, ngclass, ngswitch - Structural directives - A structure directive basically deals with manipulating the dom elements. Structural directives have a * sign before the directive - ngif, ngfor, - Component based directives - [abs] - custom created directives - why ngoninit is their when their is constructor is also there - we should use constructor() to set up Dependency Injection, Initialization of class fields, etc. ngOnInit() is a better place to write “actual work code” that we need to execute as soon as the class is instantiated. - what is es6 features - let and const Keywords - Arrow Functions - const sum = (a, b) => { return a + b } - Multi-line Strings - `
` - Default parameters - Promises - The Promise represents the completion of an asynchronous operation. It returns a single value based on the operation being rejected or resolved pending: This is the default state of a defined promise fulfilled: This is the state of a successful promise rejected: This is the state of a failed promise var promise = new Promise((resolve, reject) => { resolve("Promise Resolved"); }) promise.then((success) => { console.log(success); }) .catch(function(error) => { console.log(error); }); - Classes - Modules - Use of transform in css - The transform CSS property lets you rotate, scale, skew, or translate an element. EX: transform: rotate(20deg); - use when background-img used from css means img path added in css file - background-size: 300px 150px; - single tone services - A singleton service is a service for which only one instance exists in an application - the preferred way to create a singleton service is to set providedIn to root on the service's @Injectable() decorator. This tells Angular to provide the service in the application root or Declare service in the providers’ array of @ngModule. - Concept of services in angular - let you define code or functionalities that are then accessible and reusable in many other components in your Angular project - Global variable in angular - Using @Injectable() in class and declare in providers and than just import where u want to use, create component with class and declare variable using export and u can use anywhere in component by import - What is injectable - The @Injectable() decorator defines a class as a service in Angular and allows Angular to inject it into a component as a dependency. - what is tls files in angular - No idea - closer and inner function - Inner function EX: one function add inside another function function init() { var name = 'Mozilla'; // name is a local variable created by init function displayName() { // displayName() is the inner function, a closure console.log(name); // use variable declared in the parent function } displayName(); } init(); - Clouser ex: displayName() inner function is returned from the outer function before being executed. function makeFunc() { const name = 'Mozilla'; function displayName() { console.log(name); } return displayName; } const myFunc = makeFunc(); myFunc(); - subject - A subject is an observable that can multicast i.e. talk to many observers - behavior subject - A BehaviorSubject holds one value. When it is subscribed it emits the value immediately. A Subject doesn't hold a value. - hot vs cold observable - When the data is produced by the Observable itself, we call it a cold Observable. When the data is produced outside the Observable, we call it a hot Observable. - Cold observable EX const observable = Rx.Observable.create((observer) => { observer.next(Math.random()); }); - Hot observable EX const random = Math.random() const observable = Rx.Observable.create((observer) => { observer.next(random); }); - what is ngrx - Ngrx is a group of Angular libraries for reactive extensions. Ngrx/Store implements the Redux pattern using the well-known RxJS observables of Angular 2. - What are Single Page Applications (SPA)? - Single page applications are web based applications that only need to be loaded once, with new functionality consisting of only minor changes to the user interface. It does not load new HTML pages to display the content of the new page - What is data binding in Angular? - Data binding is one of the most significant and effective elements for creating communication between the DOM and the component. There are Four types of Data binding in Angular: Property Binding Event Binding String Interpolation Two way data binding - Property Binding: One method of data binding is called property binding. In property binding, we connect a DOM element's property to a field that is a declared property in our TypeScript component code. In reality, Angular transforms string interpolation into property binding internally. - Event Binding: Using event binding, you may respond to DOM events like button clicks and mouse movements. When a DOM event (such as a click, change, or keyup) occurs, the component's designated method is called. 1. What is Angular? - Angular is an open-source, JavaScript framework wholly written in TypeScript. It uses HTML's syntax to express your application's components clearly. 2. Why were client-side frameworks like Angular introduced? - web developers used VanillaJS and jQuery to develop dynamic websites but, as the logic of one's website grew, the code became more and more tedious to maintain. - client-side frameworks like Angular came into the picture, which made life easier for the developers by handling separation of concerns and dividing code into smaller bits of information 3. What is TypeScript? - TypeScript is a programming language developed and maintained by Microsoft. It is a strict syntactical superset of JavaScript - TypeScript is a primary language for Angular application development. It is a superset of JavaScript with design-time support for type safety and tooling. Browsers can't execute TypeScript directly. 4. What are Templates in Angular? - Angular Templates are written with HTML that contains Angular-specific elements and attributes. In combination with the model and controller's information, these templates are further rendered to provide a dynamic view to the user. 5. What are Components in Angular? - Components are the basic building blocks of the user interface in an Angular application. Every component is associated with a template and is a subset of directives. 6. What are some of the advantages of Angular over other frameworks? - Angular provides a number of built-in features like,routing, state management, rxjs library and http servicesstraight out of the box. This means that one does not need tolook for the above stated features separately. They are allprovided with angular. - Angular uses HTML to render the UI of an application. HTML isa declarative language and is much easier to use than JavaScript. - Google announced Long-term support for Angular. This means that Google plans to stick with Angular and further scale up its ecosystem. 7. What is AOT compilation? What are the advantages of AOT? - Every Angular application consists of components and templates which the browser cannot understand. Therefore, all the Angular applications need to be compiled first before running inside the browser. - Angular provides two types of compilation: - JIT(Just-in-Time) compilation - this is default - AOT(Ahead-of-Time) compilation - need to add with --aot - JIT vs AOT - JIT is more suitable for development mode. & AOT is much suitable in the case of Production mode. - JIT downloads the compiler and compiles code exactly before Displaying in the browser. -> AOT has already complied with the code while building your application, so it doesn’t have to compile at runtime. - Loading in JIT is slower than the AOT because it needs to compile your application at runtime. -> Loading in AOT is much quicker than the JIT because it already has compiled your code at build time. 58 Modules - A module is a place where we can group components, directives, services, and pipes. Module decides whether the components, directives, etc can be used by other modules, by exporting or hiding these elements. Every module is defined with a @NgModule decorator. 9. How does an Angular application work? - Every Angular app consists of a file named angular.json. This file will contain all the configurations of the app. While building the app, the builder looks at this file to find the entry point of the application. Following is an image of the angular.json file: "build": { "builder": "@angular-devkit/build-angular:browser", "options": { "outputPath": "dist/angular-starter", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", "tsConfig": "tsconfig.app.json", "aot": false, "assets": [ "src/favicon.ico", "src/assets" ], "styles": [ "./node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css", "src/style.css" ] } } websocket API in html: - Inside the build section, the main property of the options object defines the entry point of the application which in this case is main.ts. - The main.ts file creates a browser environment for the application to run, and, along with this, it also calls a function called bootstrapModule, which bootstraps the application. These two steps are performed in the following order inside the main.ts file: import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; platformBrowserDynamic().bootstrapModule(AppModule) - In the above line of code, AppModule is getting bootstrapped. - The AppModule is declared in the app.module.ts file. This module contains declarations of all the components. 10. What are lifecycle hooks in Angular? Explain a few lifecycle hooks. - Contstructor - ngOnChange - ngOnInit - ngDoCheck - ngAfterContentInit - ngAfterContentChecked - ngAfterViewInit - ngAfterViewChecked - ngOnDestroy 11. Explain string interpolation and property binding in Angular. - String Interpolation in Angular 8 is a one-way data-binding. - Data-binding is a feature in angular, which provides a way to communicate between the component(Model) and its view(HTML template). - Data-binding can be done in two ways, one-way binding and two-way binding. 12. How are observables different from promises? promise vs observable - Emits a single value -> Emits multiple values over a period of time - Not Lazy -> Lazy. An observable is not called until we subscribe to the observable - Cannot be cancelled -> Can be cancelled by using the unsubscribe() method 13. Explain MVVM architecture - (15) https://www.interviewbit.com/angular-interview-questions/ - we update anything in view, it gets updated in model, change anything in model, it shows up in view, which is what we call 2-way binding. 12. What are decorators in Angular? - Decorators are design patterns used to isolate the modification or decoration of a class without modifying the source code. - In AngularJS, decorators are functions that allow a service, directive or filter to be modified prior to its usage. - Class decorators, such as @Component and @NgModule - Property decorators for properties inside classes, such as @Input and @Output - Method decorators for methods inside classes, such as @HostListener - Parameter decorators for parameters inside class constructors, such as @Inject 15. What are Pipes in Angular? - Pipes are simple functions designed to accept an input value, process, and return as an output, a transformed value in a more technical understanding 16. What is an ngModule? - NgModules are containers that reserve a block of code to an application domain or a workflow. @NgModule takes a metadata object that generally describes the way to compile the template of a component and to generate an injector at runtime. 17. What is view encapsulation in Angular? - View encapsulation defines whether the template and styles defined within the component can affect the whole application or vice versa. Angular provides three encapsulation strategies: - Emulated - styles from the main HTML propagate to the component. - Native - styles from the main HTML do not propagate to the component. - None - styles from the component propagate back to the main HTML and therefore are visible to all components on the page. https://codecraft.tv/courses/angular/components/templates-styles-view-encapsulation/ 18. what is rxjs - RxJS is a library for composing asynchronous and event-based programs by using observable sequences. It provides one core type, the Observable, satellite types (Observer, Schedulers, Subjects) and operators inspired by Array#extras (map, filter, reduce, every, etc) to allow handling asynchronous events as collections. 19. rxjs - Observable: Observable in Angular is a feature that provides support for delivering messages between different parts of your single-page application. - Observer: An Observer is a consumer of values delivered by an Observable, is a collection of callbacks that knows how to listen to values delivered by the Observable. (onNext, onError, onComplete) - Subscription: represents the execution of an Observable, is primarily useful for cancelling the execution. - Operators: are pure functions that enable a functional programming style of dealing with collections with operations like map, filter, concat, reduce, etc. - Subject: is equivalent to an EventEmitter, and the only way of multicasting a value or event to multiple Observers. - Schedulers: are centralized dispatchers to control concurrency, allowing us to coordinate when computation happens on e.g. setTimeout or requestAnimationFrame or others. 20. redux - Redux is a JavaScript library for managing application state. - Store - The store is a single JS object that contains state of application. - The store is a single JS object. To create a store you simple need to a add a TypeScript file to the project and declare a new interface type which contains all the properties you’d like to keep in the store. - Actions - Actions are the only source of information for the store as per Redux official documentation. It carries a payload of information from your application to store. - Reducers - A reducer is a function that specifies how the state changes in response to an action. - What’s important to understand is the fact that a reducer function does not modify the state. It always returns a new state object with the modifications included. 21. diff between d-none and visibility:hidden - display:none means that the tag in question will not appear on the page at all (although you can still interact with it through the dom). ... visibility:hidden means that unlike display:none, the tag is not visible 22. Difference between TypeScript and JavaScript: - TypeScript is known as an Object-oriented programming language whereas JavaScript is a scripting language. - TypeScript has a feature known as Static typing but JavaScript does not support this feature. - TypeScript supports Interfaces but JavaScript does not. 23. Dependency injection - is a design pattern in which a class requests dependencies from external sources rather than creating them - Types of Dependency Injection in Angular - Constructor injection: Here, it provides the dependencies through a class constructor. - Setter injection: The client uses a setter method into which the injector injects the dependency. - Interface injection: The dependency provides an injector method that will inject the dependency into any client passed to it. On the other hand, the clients must implement an interface that exposes a setter method that accepts the dependency. 24. async pipes - The async pipe subscribes to an Observable or Promise and returns the latest value it has emitted. When a new value is emitted, the async pipe marks the component to be checked for changes. When the component gets destroyed, the async pipe unsubscribes automatically to avoid potential memory leaks. 25. what is observable - Observable in Angular is a feature that provides support for delivering messages between different parts of your single-page application. 26. why tsconfig.json is there in angular project - The presence of a tsconfig.json file in a directory indicates that the directory is the root of a TypeScript project. The tsconfig. json file specifies the root files and the compiler options required to compile the project. 27. let and var diff - let is block-scoped. -> var is function scoped. - Variables defined without let can be redeclared. -> Variables defined with let can not be redeclared. - declared inside a { } block cannot be accessed from outside -> declared inside a { } block can be accessed from outside - let must be declare before use -> "" 28. Why TypeScript is developed while having JavaScript? When JavaScript was developed, the JavaScript development team introduced JavaScript as a client-side programming language. But as people were using JavaScript, developers also realized that JavaScript could be used as a server-side programming language. However, as JavaScript was growing, JavaScript code became complex and heavy. Because of this, JavaScript wasn’t even able to fulfill the requirement of an Object-Oriented Programming language. This prevented JavaScript from succeeding at the enterprise level as a server-side technology. So TypeScript was created by the development team to bridge this gap. - code is written in JavaScript can be converted to TypeScript by changing the extension from .js to .ts. - TypeScript can be compiled to run on any browser, device, or operating system. TypeScript is not specific to any single environment. - TypeScript is known as an Object-oriented programming language whereas JavaScript is a scripting language. 29. What's the Router Outlet in Angular? The router-outlet is a directive that's available from the @angular/router package and is used by the router to mark where in a template, a matched component should be inserted. Thanks to the router outlet, your app will have multiple views/pages and the app template acts like a shell of your application. Any element, you add to the shell will be rendered in each view, only the part marked by the router outlet will be changed between views. 30. What are Annotations in Angular? Annotations in Angular are used for creating an annotation array. They are the metadata set on the class that is used to reflect the Metadata library. 31. What is the PipeTransform interface? As the name suggests, the interface receives an input value and transforms it into the desired format with a transform() method. It is typically used to implement custom pipes. import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ name: 'demopipe' }) export class DemopipePipe implements PipeTransform { transform(value: unknown, ...args: unknown[]): unknown { return null; } } 32. What are filters in Angular? Name a few of them. Filters are used to format an expression and present it to the user. They can be used in view templates, controllers, or services. Some inbuilt filters are as follows. date - Format a date to a specified format. filter - Select a subset of items from an array. Json - Format an object to a JSON string. limitTo - Limits an array/string, into a specified number of elements/characters. lowercase - Format a string to lowercase. 33. 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. 34. 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 at the start of the application. 35. what is eagerly loaded module modules are eagerly loaded which means that they are all loaded when the application launches. 36. What is style mining 37. What is diff between JS expression and Angular expression getter & setter method map() will return a new array as per the conditions applied. - modification of array forEach() will not return anything. forEach() returns undefined. filter()method will return an array of matching elements else will return an empty array if no matching happens. - get new array filtered value https://www.besanttechnologies.com/angular-8-interview-questions-answers https://www.interviewbit.com/angular-8-interview-questions/ angular universal - single tone service - A singleton service is a service for which only one instance exists in an application. access modifiers in typescript Public, Private, Protected 1. What is Angular? 2. Why were client-side frameworks like Angular introduced? 3. What is TypeScript? 4. What are Templates in Angular? 5. What are Components in Angular? 6. What are some of the advantages of Angular over other frameworks? 7. What is AOT compilation? What are the advantages of AOT? 10. What are lifecycle hooks in Angular? Explain a few lifecycle hooks. 12. How are observables different from promises? 12. What are decorators in Angular? 15. What are Pipes in Angular? 17. What is view encapsulation in Angular? 20. redux 21. diff between d-none and visibility:hidden 23. Dependency injection 25. what is observable - How can we print nested array in html - what is recursive function - How can we use multiple css in 1 component - How to use multiple bootstrap in angular application - What is use of view child - How can we show html of 1 component to another component ->