Q & A - Angular Questions & Answers


Q&A 1.

What are controllers in AngularJS?

A controller is defined using ng-controller directive. A controller is a javaScript object that contains the data and functions. Each controller accepts $scope as a parameter.

Q&A 2.

What is a model in angular?

Within the scope objects are like model in angular. In MVVM pattern it is like a glue between controller and a view. We can access model properties using its property name. Objects are declared in angular just like javascript objects.

$scope.student = {
firstName: "Mustafa",
lastName: "",

Q&A 3.

What does the $scope refers to in AngularJS?

$scope refers to application which uses the Controller object in angular. The $scope is passed as an argument to constructor of controller. Using $scope we can access all objects like model and a function in a controller. The scope is the binding part between the HTML view and the JavaScript controller.

Q&A 4.

What is ng-include directive?

ng-include directive is used to add external html files into application. This ng-include directive helps us to add html page dynamically into angular application.
For example we can create header menu in header.html and include within home page html.

<body ng-app="myapp" >
 <div ng-include="'header.html'"></div>
 <p>My first angular app.</p>

Q&A 5.

How arrays are handled in angular?

AngularJS arrays are like JavaScript arrays, is a list of items. For Example declaring an array.
$scope.numbers = [1,2,3,4,5];

Q&A 6.

What is Scope Inheritance in angular?

Scope is controller specific, if we define nested controllers, then the child controller inherits the scope of its parent controller.

Q&A 7.

What are filters in angular?

Filters are used to select a subset of items from an array and returns a new array. They are used in expressions or directives using pipe (|) character followed by a filter. There are some common filters available in angular like: uppercase, lowercase, currency, and OrderBy filter.

<p>The name is {{ firstName | lowercase }}</p>

Q&A 8.

What does the currency Filter do?

The currency filter formats a number as a currency. For example:

<p>Price = {{ price | currency : "$" }}</p>

Q&A 9.

Does Angular follows MVVM Pattern?

Yes, angular is based on MVC model but rather being close to MVVM (Model-View-ViewModel). Giving abstraction to model, view and controller.

Q&A 10.

What is Routing in angular?

It is concept of switching views. In AngularJS, routing is what allows you to create Single Page Applications. AngularJS routes enable you to create different URLs for different content in your application. And show multiple contents depending on which route is chosen.

Related Quiz Content

This website is using cookies to make user experience of the site better. More info. OK