Angular JS Interview Question Set 3
Categories: Angular JS
Explain the concept of scope hierarchy
Each angular application consists of one root scope but may have several child scopes. As child controllers and some directives create new child scopes, an application can have multiple scopes. When new scopes are formed or created, they are added as a children of their parent scope. They also create a hierarchical structure similar to DOM.
Explain the main difference between AngularJS and backbone.js
AngularJSBackbone.js
AngularJS is a JavaScript-based open-source framework which is designed to support dynamic web applications.backbone.js is a framework which abstracts DOM into views and data into models and then binds both using events.
It’s performance is good as it provides two-way data binding processBackbone.js technology offers faster performance than AngularJS if the data sets are small
Who created Angular JS?
AngularJS was developed by Adam Abrons and Misko Hevery. Currently, it is developed by Google.
What is orderby filter in AngularJS?
Orderby filter in AngularJS orders the array based on specified criteria. Following example states how you can order product by price.
<ul>
<li ng-repeat = "company in product.products | orderBy:'price">
{{ company.product + ', price:' + product.price }}
</li>
</ul>
What is ng-non-bindable in AngularJS?
Ng-non-bindable specifies AngularJs to not compile the HTML element and its child nodes. For example:
<title ng-non-bindable > </title>
Explain the use of double click event in AngularJS
double click event of AgularJS let you to specify custom behavior on double click event of mouse on a web page like:
<ELEMENT ng-dblclick="{expression}">
...
</ELEMENT>
Explain ng-click directives in AngularJS with example
Ng-click directives can be used in a scenario when you have to click on the button or want to perform any operation.
Example:
<button ng-click="count = count ++">Click</button>
Why use ng-include in AngularJS?
Ng-include in AngularJS helps you to embed HTML pages within a single HTML page. Example:
<div ng-app = "" ng-controller = "interviewController">
<div ng-include = "'first.htm'"></div>
<div ng-include = "'phases.htm'"></div>
</div>
How can you make an ajax call using Angular JS?
AngularJS offers $https: control that helps you to make ajax call to read server data. The server makes a database call in order to get the required records. Once your data in JSON format is ready, you can use $https: to retrieve data from the server in the following manner:
function employeeController($scope,$https:) {
var url = "tasks.txt";
$https.get(url).success( function(response) {
$scope.employee = response;
});
}
Explain the use of $routeProvider
In Angular JS $routeProvider sets the URL configuration. It maps with the related ng-template or HTML page and attaches a controller with the same.