angular_interview_questions-2
angular_interview_questions-2
• Angular History
• Single Page App (SPA)
Agenda • Angular CLI
• Angular Configuration
• Angular Building Blocks
• Components and Decorators
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q&A:
Angular History
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q1. What is Angular?
• An open-source framework for building single page applications
(SPA) using web technologies like html, css and js.
• Angular is written in TypeScript and follow TypeScript syntax to
write code.
• Empowers developers to build applications for browsers, mobiles,
or desktop
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q2. How many versions of Angular have been released?
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q3. What is difference between Angular2 and Angular1?
Angular2+ Angular 1.x
• Based on components • Based on controller and scope
• Improved DI • Supports DI
• Mobile First • Not built with mobile first
• Supports ES5/6, TS or Dart • Supports ES5/6 or Dart
• Angular CLI • Doesn’t have CLI
• Class is only way to define services • factory, service, provider, value and
in Angular2 constant are used for services
• Runs on client-side & server-side • Run on only client-side
• bootstrapModule() function is used • ng-app and angular.bootstrap()
to initialize function are used to initialize
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Difference between Angular2 and Angular1 Contd..
Angular2+ Angular 1.x
• Supports Pipe • Support filters
• Supports camelCase & PascalCase • Supports spinal-case & camelCase
syntaxes like ngModel, ngForm and syntaxes like ng-model, ng-class and
NgForm ngModel
• Use Html DOM elements • Use it’s own directives like ng-click,
properties and events ng-show and ng-src etc.
• Use () for events and [] for • Doesn’t support () and [] based
attributes syntax
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q4. How to Set Up Angular Dev Environment?
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q&A:
Single Page App (SPA)
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q1. What is single page application?
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q2. What are single page application examples?
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q3. What frameworks can be used to build SPA?
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q4. How MPA are different from SPA?
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q&A:
Angular CLI
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q1. What is Angular CLI?
Options Usage
Help ng --help
Build ng build --env
Build and Run ng serve
Testing ng test
End-End Testing ng e2e
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q3. What are Angular CLI Commands?
Scaffold Usage In Short
Module ng generate module my-module ng g m my-module
Component ng generate component my-component ng g c my-component
Directive ng generate directive my-directive ng g d my-directive
Pipe ng generate pipe my-pipe ng g p my-pipe
Service ng generate service my-service ng g s my-service
Guard ng generate guard my-guard ng g g my-guard
Class ng generate class my-class ng g cl my-class
Interface ng generate interface my-interface ng g i my-interface
Enum ng generate enum my-enum ng g e my-enum
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q4. What are Angular CLI Advantages?
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q&A:
Angular Configuration
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q1. What is the role of angular.json file?
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q2. What is the role of package.json file?
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q4. What is tsconfig.json file?
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q5. What is karma.conf.js file?
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q6. What are Polyfills?
• Polyfills are scripts that ensure that your application code (which use the
new browser features) do not break in the older browsers.
• Polyfills makes our application compatible for different browsers especially
IE old versions IE8, IE9 and IE10.
• Polyfills.ts file is used by angular to setup everything for browser
compatibility.
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q7. What is the role of Webpack in Angular?
• The Angular build process uses webpack behind the scenes to transpile
TypeScript to JavaScript, transform Sass files to CSS, and many other tasks.
• Webpack is an open-source JavaScript-based build tool.
• Used to bundle various assets like JavaScript, CSS, and Images for usage in a
browser.
• Webpack takes the dependencies and generates a dependency graph which
allows web developers to use a modular approach for development.
• Used from the command line, or can be configured using a config file using
webpack.config.js.
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q&A:
Angular Building Blocks
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q1. What are Angular building blocks?
• Modules • Routing
• Components • Forms
• Templates • Services
• Metadata • Dependency injection
• Data binding
• Directives
• Pipes
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q2. Do explain Angular initialization process?
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q3. What is Module?
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q4. What are module main properties?
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q5. What are Built-In Modules?
• Built-In library & third part modules can be installed using npm
manager
• Built-In modules, components, services, directives etc. can be
imported by using built-In library modules
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q&A:
Components and Decorators
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q1. What is a Component?
• A type of directives with template, styles and logic for user interaction
• Exported as a custom HTML tag like as:
▪ <my-component></my-component>
• Initialized by Angular Dependency Injection engine
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
• Component Example
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q2. How Components can help you to make Webpage?
HEADER COMPONENT
ARTICLE CATEGORIES
COMPONENT COMPONENT
FOOTER COMPONENT
ROOT COMPONENT
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q3. What is a Template?
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q4. What is a Decorator?
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q5. What are different types of decorators ?
• Class decorators
▪ @NgModule – Used for defining a module
▪ @Component – Used for defining a component
▪ @Directive – Used for defining a directive
▪ @Injectable – Used for injecting dependencies
▪ @Pipe – Used for defining a pipe
• Class field decorators
▪ @Input – Used for receiving data (input) from parent to child component
▪ @Output – Used for passing data (events) from child to parent component
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.
Q6. What is Metadata?
Copyright Dot Net Tricks Innovation Pvt. Ltd. | All rights Reserved.