AngularJS Interview Questions Part 4

16. What is REST in AngularJS?


REST stands for REpresentational State Transfer.

It is a style of API that operates over HTTP requests.

It uses an Internet media type such as JSON for data interchange, standard HTTP methods (GET, PUT, POST, DELETE).

REST is a stateless client-server architecture in which the web services are viewed as resources and can be identified by their URIs.

It consists of two components,

1. REST server which provides access to the resources
2. REST client which accesses and modifies the REST resources.

In REST, clients and servers exchange representations of resources by using a standardized interface and protocol.

REST is not protocol specific, but when people talk about REST they usually mean REST over HTTP.

17. What is Provider method in AngularJS?


A provider is an object with a $get() method. The injector calls the $get method to create a new instance of a service.

The provider method allows to create a configurable service where we can set input per application for the service created using the provider().

AngularJS uses $provide to register new providers.

18. What are the attributes can be used during creation of a new AngularJS Directives?


The following attributes can be used during creation of a new AngularJS Directives,
  • Restrict
  • TemplateUrl
  • Template
  • Replace
  • Transclude
  • Scope
  • Controller
  • Require
  • Link
  • Compile

19. What is the difference between AngularJS and JQuery?


AngularJS supports the MVC pattern while JQuery does not support MVC pattern.

AngularJS file size is quite heavier than that of the JQuery file size.

AngularJS has RESTful API. JQuery don't have RESTful API.

AngularJS has the feature called Two Way Data Binding. JQuery don't have Two Way Data Binding feature.

AngularJS is supported by Deep Linking Routing whereas JQuery doesn't.

20. What is $scope in AngularJS?


The $scope is an object that binds view (DOM element) with the controller.

It is an object which refers to an application model. It can be used for communication between view and controller.


<!DOCTYPE html>
    <script src=""></script>
        <div ng-app="myApp" ng-controller="myCtrl">
            var app = angular.module('myApp', []);
            app.controller('myCtrl', function($scope)
                $scope.carname = "Audi";

When adding properties to the $scope object in the controller, the view (HTML) gets access to these properties. In the view, you do not use the prefix $scope, you just refer to a propertyname, like {{carname}}.