AngularJS Flashcards
What is AngularJS?
AngularJS is an MVC framework for building web applications. The core features include HTML enhanced with custom component and data-binding capabilities, dependency injection and strong focus on simplicity, testability, maintainability and boiler-plate reduction.
AngularJS is a powerful JavaScript based development framework to create RICH Internet Application (RIA).
AngularJS provides developers options to write client side application (using JavaScript) in a clean MVC (Model View Controller) way.
Application written in AngularJS is cross-browser compliant. AngularJS automatically handles JavaScript code suitable for each browser.
What are Directives?
At a high level, directives are markers on a DOM element (such as an attribute, element name, comment or CSS class) that tell AngularJS’s HTML compiler ($compile) to attach a specified behavior to that DOM element (e.g. via event listeners), or even to transform the DOM element and its children.
What are AngularJS Prefixes $ and $$ for?
To prevent accidental name collisions with your code, AngularJS prefixes names of public objects with $ and names of private objects with $$
What is data binding in AngularJS?
Data binding is the automatic synchronization of data between model and view components. ng-model directive is used in data binding.
What is scope in AngularJS?
Scopes are objects that refer to the model. They act as glue between controller and view.
What are the controllers in AngularJS?
Controllers are JavaScript functions that are bound to a particular scope. They are the prime actors in AngularJS framework and carry functions to operate on data and decide which view is to be updated to show the updated model based data.
What are the services in AngularJS?
AngularJS come with several built-in services. For example $https: service is used to make XMLHttpRequests (Ajax calls). Services are singleton objects which are instantiated only once in app.
What are the filters in AngularJS?
Filters select a subset of items from an array and return a new array. Filters are used to show filtered items from a list of items based on defined criteria.
Explain directives in AngularJS.
Directives are markers on DOM elements (such as elements, attributes, css, and more). These can be used to create custom HTML tags that serve as new, custom widgets. AngularJS has built-in directives (ng-bind, ng-model, etc) to perform most of the task that developers have to do.
Explain templates in AngularJS.
Templates are the rendered view with information from the controller and model. These can be a single file (like index.html) or multiple views in one page using “partials”.
What is routing in AngularJS?
It is concept of switching views. AngularJS based controller decides which view to render based on the business logic.
What are the advantages of AngularJS?
AngularJS provides capability to create Single Page Application in a very clean and maintainable way.
AngularJS provides data binding capability to HTML thus giving user a rich and responsive experience.
AngularJS code is unit testable.
AngularJS uses dependency injection and make use of separation of concerns.
AngularJS provides reusable components.
With AngularJS, developer writes less code and gets more functionality.
In AngularJS, views are pure html pages, and controllers written in JavaScript do the business processing.
AngularJS applications can run on all major browsers and smart phones including Android and iOS based phones/tablets.
What are the disadvantages of AngularJS?
Not Secure − Being JavaScript only framework, application written in AngularJS are not safe. Server side authentication and authorization is must to keep an application secure.
Not degradable − If your application user disables JavaScript then user will just see the basic page and nothing more.
Which are the core directives of AngularJS?
ng-app − This directive defines and links an AngularJS application to HTML.
ng-model − This directive binds the values of AngularJS application data to HTML input controls.
ng-bind − This directive binds the AngularJS Application data to HTML tags.
Explain AngularJS boot process.
HTML document is loaded into the browser, and evaluated by the browser. AngularJS JavaScript file is loaded; the angular global object is created. Next, JavaScript which registers controller functions is executed.
Next AngularJS scans through the HTML to look for AngularJS apps and views. Once view is located, it connects that view to the corresponding controller function.
Next, AngularJS executes the controller functions. It then renders the views with data from the model populated by the controller. The page gets ready.
What is MVC?
Model View Controller or MVC as it is popularly called, is a software design pattern for developing web applications. A Model View Controller pattern is made up of the following three parts:
Model − It is the lowest level of the pattern responsible for maintaining data.
View − It is responsible for displaying all or a portion of the data to the user.
Controller − It is a software Code that controls the interactions between the Model and View.
Explain ng-app directive.
ng-app directive defines and links an AngularJS application to HTML. It also indicate the start of the application.
Explain ng-model directive.
ng-model directive binds the values of AngularJS application data to HTML input controls. It creates a model variable which can be used with the html page and within the container control( for example, div) having ng-app directive.
Explain ng-bind directive.
ng-bind directive binds the AngularJS Application data to HTML tags. ng-bind updates the model created by ng-model directive to be displayed in the html tag whenever user input something in the control or updates the html control’s data when model data is updated by controller.