Angular Interview Questions and Answers Set 4

31. Explain MVVM architecture.

MVVM architecture is an architectural pattern used mainly in software engineering. It stands for Model-View-ViewModel. MVVM is a variation of the traditional MVC (Model-View-Controller) software design pattern. The main difference between the two is that MVVM separates the user interface logic from the business logic, while MVC separates the data access logic from the business logic. This separation of concerns makes it easier to develop, test, and maintain software applications.
The Model layer in MVVM architecture is responsible for storing and managing data. It can be a database, a web service, or a local data source. The View layer is responsible for displaying data to the user. It can be a graphical user interface (GUI), a command-line interface (CLI), or a web page. The ViewModel layer is responsible for handling user input and updating the View layer accordingly. It contains the business logic of the application.
MVVM architecture is often used in conjunction with other software design patterns, such as Model-View-Presenter (MVP) and Model-View-Controller (MVC). These patterns can be used together to create a complete software application.
MVVM architecture is a popular choice for modern software applications. It allows developers to create applications that are more responsive and easier to maintain. Additionally, MVVM architecture can be used to create applications that can be easily ported to different platforms.

32.What do you mean by String Interpolation?

string interpolation is the process of evaluating a string literal that contains one or more placeholders. It yields a result in which the placeholders are replaced with their values.String interpolation in Angular is used to display dynamic data on an HTML template.

33. What is an AOT compilation in Angular?

The Angular ahead-of-time (AOT) compiler converts the Angular code into JavaScript code. The conversion happens before the browser downloads and runs the code. To achieve faster rendering in the browser, Compile your application during the build process.

34.What is ECMA Script ?

ECMAScript stands for European Computer Manufacturers Association Script.ECMAScript is a standard script language, developed with the cooperation of Netscape and Microsoft and mainly derived from Netscape’s JavaScript, the widely-used scripting language that is used in Web pages.

35. How To Bootstrap Your Angular App For Multiple Modules?

AngularJS is automatically initialized for one module. When we have multiple modules, we combine them into a single module and thus the angular app will be automatically initialized for the newly created module. Other modules act as dependent modules for this newly created module.

Let’s take an example, suppose we have two modules: module1 and model2. To initialize the app automatically, based on these two modules following code is used

<html>
<head>
<title>
Multiple modules bootstrap
</title>
<script src=”lib/angular.js”></script>
<script>
//module1
var app1 = angular.module(“module1”, []); app1.controller(“Controller1”, function ($scope) { $scope.name = “Welcome”; });

//module2

var app2 = angular.module(“module2”, []); app2.controller(“Controller2”, function ($scope) { $scope.name = “World”; });

//module3 dependent on module1 & module2

angular.module(“app”, [“module1”, “module2″]);
</script>
</head>
<body>
<!–angularjs autobootstap process–>
<div ng-app=”app”>
<h1>Multiple modules bootstrap</h1>
<div ng-controller=”Controller2″>
</div>
<div ng-controller=”Controller1″>
</div>
</div>
</body>
</html>

ANGULAR TRAINING
Weekend / Weekday Batch

 

36. What are modules in Angular?

A module is a mechanism or container to group the components, directives, pipes and services.It helps to encapsulate the code that deals with several aspects of an application. Developers can create modules using the NgModule decorator.

37. Can angular applications (ng-app) be nested within each other?

AngularJS applications cannot be nested within each other.

38. Can you bootstrap multiple angular applications on same element?

If you try to do that then it will show an error “App Already Bootstrapped with this Element”. This usually happens when you accidentally use both ng-app and angular.bootstrap to bootstrap an application. You can also get this error if you accidentally load AngularJS itself more than once.

39. What is Basic Authentication? How to implement it using Angular??

The Basic Authentication Interceptor intercepts http requests from the application to add basic authentication credentials to the Authorization header if the user is logged in. It’s implemented using the HttpInterceptor class that was introduced in Angular 4.3 as part of the new HttpClientModule.

40. What is Buffer (window storage)?

Angular window storage, offers an easy interface for usage of the web storage and cookies.It works as a store manager so no need to worry about where to store information.