angularjs interview questions and answers by shailendra chauhan

DOT NET TRICKS TRAINING CENTER B 64, Near SBI Bank, Sector 2 Noida, Metro Noida Sector 15, Uttar Pradesh (India) www.dot

Top 10 Angular js Interview question and answers for freshers and experienced online videos

To get the latest information on AngularJS, I encourage you to follow the official AngularJS website at www.angularjs.org. I also encourage you to subscribe to my blog at www.dotnet-tricks.com that contains AngularJS, jQuery Mobile, .NET, C#, ASP.NET MVC, EF and many more tips, tricks and tutorials.

I hope you will enjoy this book and find it useful. At the same time I also encourage you to become a continue reader of the blog www.dotnet-tricks.com and be the part of the discussion. But most importantly practice a lot and enjoy the technology. That’s what it’s all about.

AngularJS Interview Questions and Answers book has been written with the intent of preparing yourself with solid foundations on AngularJS – in a short time without wasting your time in googling. As an author, I have tried to present each topic with the help of appropriate questions with answers which have suitable examples.

AngularJS Interview Questions and Answers eBook is the collection of the latest and most frequently asked questions about the AngularJS in the technical interview. This eBook covers all the elementary, intermediate, and advanced-level AngularJS Interview Questions along with their detailed and precise answers which will increase your possibility of the selection in the job interview. This book will not only help you to prepare yourself for an interview but it will also guide you to clear your core Angular concepts from how Angular works to advance concepts of AngularJS.

AngularJS Interview Questions and Answers book has been written with the intent of preparing yourself with solid foundations on AngularJS within a short span of time. By going through this book, you don’t have to spend time on the internet to search for AngularJS interview questions as an author he has tried to present each topic with the appropriate questions and answers along with the suitable examples. This eBook contains top AngularJS interview questions and answers which were asked in the top MNC companies, prepared by our industry expert trainer to help you get the best job in the industry.

Shailendra Chauhan is the Founder and CEO of DotNetTricks which is a brand when it comes to e-Learning. DotNetTricks provides training and consultation over an array of technologies like Cloud, .NET, Angular, React, Node, Microservices, Containers and Mobile Apps development. He has been awarded as Microsoft MVP Seven times in a row (2016-2021). He has changed many lives from his writings and unique training programs. He has a number of most sought-after books to his name which has helped job aspirants in cracking tough interviews with ease.

an html + click here snippet; $scope.trustedSnippet = $sce.trustAsHtml(snippet); //sce=Strict Contextual Escaping }); The snippet may contain HTML, CSS, URLs and JavaScript code which you want to safely render in your app. Q109. What is Angular 2.0? Ans. Angular 2.0 is being written with AtScript, but that doesnt mean you have to write your application code with AtScript or know anything about AtScript to use Angular 2.0. You can easily write with TypeScript, ES6, ES5, CoffeeScript etc. whatever you like. It is still in development phase (at the time of writing this book). Q110. What is AtScript? Training Highlights   Learn from qualified and experienced professional Small batches to ensure personal attention  Hands-on real application development    65 Recorded session of your class Training course material Prepare yourself for interview and get great jobs Page The aim of AtScript is to make type annotation data available at runtime to enhance JavaScript with type, field and metadata annotations. 65 Ans. AtScript is Google’s new superset for JavaScript. It enhances JavaScript with new features to make it more robust. It is not only designed to run on top of ECMAScript 5 and ECMAScript 6, but on the top of Microsoft’s superset TypeScript language as well. DOT NET TRICKS TRAINING CENTER B 64, Near SBI Bank, Sector 2 Noida, Metro Noida Sector 15, Uttar Pradesh (India) www.dotnet-tricks.com, www.dotnettricks.com +91 98 71 749695, +91 120 426 5198 Others Free Interview Books As the author, I am absolutely delighted to share my others interview books as well. I want these books to reach as many techy people as possible. You can also download these books from my blog www.dotnet-tricks.com in PDF format absolutely free. ASP.NET MVC Interview Questions & Answers This book is appropriate for novice as well as for senior level professionals who wants to strengthen their skills before appearing for an interview on ASP.NET MVC. This book is equally helpful to sharpen their programming skills and understanding ASP.NET MVC in a short time. This book is not only the ASP.NET MVC interview book but it is more than that. This book helps you to get the depth knowledge of ASP.NET MVC with a simple and elegant way. Download LINQ Interview Questions & Answers This book is appropriate for novice as well as for senior level professionals who want to understand what LINQ does, how it does in .NET languages like C# and VB. This book is equally helpful to show you the best of using LINQ with the help of many practical ways to make your daily programming life easier and more productive. This book is not only help you to learn LINQ but it also be helpful to learn Entity Framework. This book helps you to do hands on LINQ as well as preparing yourself for an interview on LINQ. Page 66 Download Training Highlights   Learn from qualified and experienced professional Small batches to ensure personal attention  Hands-on real application development    66 Recorded session of your class Training course material Prepare yourself for interview and get great jobs

Broadcast Message : {{message}} Output $on – It listen on events of a given type. It can catch the event dispatched by $broadcast and $emit. Note – If there is no parent-child relation between your scopes you can inject $rootScope into the controller and broadcast the event to all child scopes but you cannot emit your event. You can emit your event only when you have parent-child relation and event propagation is initiated by child. However, $emit can fire an event only for all $rootScope.$on listeners. Q72. What is View in AngularJS? Ans. The view is responsible for presenting your models data to end user. Typically it is the HTML markup which exists after AngularJS has parsed and compiled the HTML to include rendered markup and bindings. Q73. How to apply validation in AngularJS? 49 Ans. AngularJS provides you built-in validation directives to validate form client side. This makes your life pretty easy to handle client-side form validations without adding a lot of extra effort. AngularJS form validations are based on the HTML5 form validators. Page AngularJS directives for form validation Here is a list of AngularJS directive which can be applied on an input field to validate its value. Training Highlights   Learn from qualified and experienced professional Small batches to ensure personal attention  Hands-on real application development    49 Recorded session of your class Training course material Prepare yourself for interview and get great jobs DOT NET TRICKS TRAINING CENTER B 64, Near SBI Bank, Sector 2 Noida, Metro Noida Sector 15, Uttar Pradesh (India) www.dotnet-tricks.com, www.dotnettricks.com +91 98 71 749695, +91 120 426 5198 Q74. How to do custom form validation in AngularJS? Ans. AngularJS allows you to create your own custom validation directives. For example, you have to compare password and confirm password fields. To achieve this task, you have to make a custom directive that will be fired whenever the password or confirm password changes. Creating custom directive to compare password and confirm password fields //defining module var myapp = angular.module(myapp, []); //creating custom directive myapp.directive(ngCompare, function () { return { require: ngModel, link: function (scope, currentEl, attrs, ctrl) { var comparefield = document.getElementsByName(attrs.ngCompare)[0]; //getting first element compareEl = angular.element(comparefield); //current field key up currentEl.on(keyup, function () { if (compareEl.val() != “”) { var isMatch = currentEl.val() === compareEl.val(); ctrl.$setValidity(compare, isMatch); scope.$digest(); } }); //Element to compare field key up compareEl.on(keyup, function () { if (currentEl.val() != “”) { var isMatch = currentEl.val() === compareEl.val(); ctrl.$setValidity(compare, isMatch); scope.$digest(); } }); } } 50 }); Page Using above created custom directive Confirm Password

Emit Message : {{message}} Child Controller Emit Page 47 Output Training Highlights   Learn from qualified and experienced professional Small batches to ensure personal attention  Hands-on real application development    47 Recorded session of your class Training course material Prepare yourself for interview and get great jobs DOT NET TRICKS TRAINING CENTER B 64, Near SBI Bank, Sector 2 Noida, Metro Noida Sector 15, Uttar Pradesh (India) www.dotnet-tricks.com, www.dotnettricks.com +91 98 71 749695, +91 120 426 5198 $broadcast – It dispatches an event name downwards to all child scopes (and their children) and notify to the registered $rootScope.Scope listeners. The event life cycle starts at the scope on which $broadcast was called. All listeners for the event on this scope get notified. Afterwards, the event traverses downwards toward the child scopes and calls all registered listeners along the way. The event cannot be canceled. Broadcasting Training Highlights   Learn from qualified and experienced professional Small batches to ensure personal attention  Hands-on real application development    48 Recorded session of your class Training course material Prepare yourself for interview and get great jobs DOT NET TRICKS TRAINING CENTER B 64, Near SBI Bank, Sector 2 Noida, Metro Noida Sector 15, Uttar Pradesh (India) www.dotnet-tricks.com, www.dotnettricks.com +91 98 71 749695, +91 120 426 5198 Parent Controller Broadcast Child Controller

Confirm password doesn’t match. Q75. What are different Angular form properties? Ans. Angular provides properties on form which help you to get information about a form or its inputs and to validate them. $valid – It is a boolean property that tells whether the form or its inputs are valid or not. If all containing form and controls are valid, then it will be true, otherwise it will be false. Syntax formName.$valid formName.inputFieldName.$valid $invalid – It is a boolean property that tells whether the form or its inputs are invalid or not. If at least one containing form and control is invalid then it will be true, otherwise it will be false. Syntax formName.$invalid formName.inputFieldName.$invalid $pristine – It is a boolean property that tells whether the form or its inputs are unmodified by the user or not. If the form or its inputs are unmodified by the user, then it will be true, otherwise it will be false. Syntax formName.inputFieldName.$pristine 51 $dirty – It is a boolean property that is actually just reverse of pristine i.e. it tells whether the form or its inputs are modified by the user or not. If the form or its inputs are modified by the user, then it will be true, otherwise it will be false. Page Syntax formName.$dirty formName.inputFieldName.$dirty Training Highlights   Learn from qualified and experienced professional Small batches to ensure personal attention  Hands-on real application development    51 Recorded session of your class Training course material Prepare yourself for interview and get great jobs DOT NET TRICKS TRAINING CENTER B 64, Near SBI Bank, Sector 2 Noida, Metro Noida Sector 15, Uttar Pradesh (India) www.dotnet-tricks.com, www.dotnettricks.com +91 98 71 749695, +91 120 426 5198 $error – This is an object hash which contains references to all invalid controls or forms. It has all errors as keys: where keys are validation tokens (such as required, url or email) and values are arrays of controls or forms that are invalid with given error. For a control, if a validation fails then it will be true, otherwise it will be false. Syntax formName.$error formName.inputFieldName.$error Q76. What are different states of a form in AngularJS? Ans. The AngularJS form goes to the following states, starting from the form rendering and when the user has finished the filling of form. State 1: pristine and invalid – When the form is first time rendered and the user has not interacted with the form yet. State 2: dirty and invalid – User has interacted with the form, but form validity has not been satisfied, yet. State 3: dirty and valid – User has finished the filling of form and the entire form validations has been satisfied Q77. What is Service in AngularJS? Ans. A service is a reusable singleton object which is used to organize and share code across your app. A service can be injected into controllers, filters, directives. AngularJS offers several built-in services (like $http, $provide, $resource, $window, $parse) which always start with $ sign. Q78. What are different ways to create service in AngularJS? Ans. There are five ways to create a service as given below: 1. 2. 3. 4. 5. Q79. Service Factory Provider Value Constant What is the difference between Factory, Service and Provider? Ans. Factory – A factory is a simple function which allows you to add some logic before creating the object. It returns the created object. Example //define a factory using factory() function app.factory(MyFactory, function () { Page 52 var serviceObj = {}; serviceObj.function1 = function () { //TO DO: }; Training Highlights   Learn from qualified and experienced professional Small batches to ensure personal attention  Hands-on real application development    52 Recorded session of your class Training course material Prepare yourself for interview and get great jobs DOT NET TRICKS TRAINING CENTER B 64, Near SBI Bank, Sector 2 Noida, Metro Noida Sector 15, Uttar Pradesh (India) www.dotnet-tricks.com, www.dotnettricks.com +91 98 71 749695, +91 120 426 5198 serviceObj.function2 = function () { //TO DO: }; return serviceObj; }); When to use: It is just a collection of functions like a class. Hence, it can be instantiated in different controllers when you are using it with constructor function. Service – A service is a constructor function which creates the object using new keyword. You can add properties and functions to a service object by using this keyword. Unlike factory, it doesn’t return anything. Example //define a service using service() function app.service(MyService, function () { this.function1 = function () { //TO DO: }; this.function2 = function () { //TO DO: }; }); When to use: It is a singleton object. Use it when you need to share a single object across the application. For example, authenticated user details. Provider – A provider is used to create a configurable service object. It returns value by using $get() function. Example 53 //define a provider using provider() function app.provider(configurable, function () { var privateName = ; this.setName = function (newName) { privateName = newName; }; this.$get = function () { return { name: privateName }; }; }); //configuring provider using config() function app.config(function (configurableService) { configurableService.setName(www.dotnet-tricks.com); }); Training Highlights   Learn from qualified and experienced professional Small batches to ensure personal attention  Hands-on real application development    Page When to use: When you need to provide module-wise configuration for your service object before making it available. 53 Recorded session of your class Training course material Prepare yourself for interview and get great jobs DOT NET TRICKS TRAINING CENTER B 64, Near SBI Bank, Sector 2 Noida, Metro Noida Sector 15, Uttar Pradesh (India) www.dotnet-tricks.com, www.dotnettricks.com +91 98 71 749695, +91 120 426 5198 Example AngularJS Service, Factory and Providers

window.document title: 58 Recorded session of your class Training course material Prepare yourself for interview and get great jobs DOT NET TRICKS TRAINING CENTER B 64, Near SBI Bank, Sector 2 Noida, Metro Noida Sector 15, Uttar Pradesh (India) www.dotnet-tricks.com, www.dotnettricks.com +91 98 71 749695, +91 120 426 5198 Q91. What is difference between $timeout and window.setTimeout in AngularJS? Ans. $timeout is an Angular service which wraps the browsers window.setTimeout() function into a try/catch block and delegates any exceptions to $exceptionHandler service. It is used to call a JavaScript function after a given time delay. The $timeout service only schedules a single call to the function. var app = angular.module(“app”, []); app.controller(“MyController”, function ($scope, $timeout) { $timeout(callAtTimeout, 1000); }); function callAtTimeout() { console.log(“Timeout occurred”); } Q92. What is difference between $interval and window. setInterval in AngularJS? Ans. $interval is an Angular service which wraps the browsers window. setInterval() function. It is also used to call a JavaScript function repeatedly within a time interval. var app = angular.module(“app”, []); app.controller(“MyController”, function ($scope, $interval) { $interval(callAtInterval, 3000); }); function callAtInterval() { console.log(“Interval occurred”); } Q93. What is Routing in AngularJS? Ans. AngularJS Routing helps you to divide your app into multiple views and bind different views to Controllers. The magic of Routing is taken care by an AngularJS service $routeProvider. $routeProvider service provides method when() and otherwise() to define the routes for your app. Routing has dependency on ngRoute module. Defining Route for your application Q94. What is AngularUI router and how it is different from ngRoute? Ans. The UI-Router is a routing framework for AngularJS built by the AngularUI team. Unlike ngRoute, it changes your angular app views based on state of the app and not based on the route URL (ngRoute). The ui-router helps you to create nested views, use multiple views on the same page, have multiple views that control a single view, and more. To use it you need to include reference of ui-router.js file into your angular app. Q95. What is $injector and $inject? Ans. $injector is a service which is used to invoke controller functions, service functions, filter functions, and any other function that might need dependencies as parameters. Angular creates only a single $injector object when an application is bootstrapped and uses that object for invoking. increment {{value()}} $inject is property which is used to inject the dependencies of a function as an array of strings. Training Highlights   Learn from qualified and experienced professional Small batches to ensure personal attention  Hands-on real application development    60 Recorded session of your class Training course material Prepare yourself for interview and get great jobs Page MyController[$inject] = [$scope, greeter]; //inject dependencies as an array of strings 60 2. Using the $inject property annotation 3. Using the inline array annotation Q97. How to do Language Internationalization in AngularJS? Ans. The angular-translate is an AngularJS module that brings i18n (internationalization) and l10n (localization) into your Angular app. It allows you to create a JSON file that represents translation data as per language. These languages specific JSON files can be lazy-loads from the server only when necessary. The angular-translate library (angular-translate.js) also provides built-in directives and filters that make the process of internationalizing simple. Training Highlights   Learn from qualified and experienced professional Small batches to ensure personal attention  Hands-on real application development    Page 61 AngularJS Internalization {{ TITLE | translate }}

I personally belive these questions and answers have helped you in your interview preparation along with learning interview questions & answers. you should learn from Dot Net Tricks Angular js online traning programs which are freely available. our Angularjs training enables you to brush-up your concepts by refering various angular js training videos.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *