16. What is REST in AngularJS?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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?
Answer:
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.
Example:
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<h1>{{carname}}</h1>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope)
{
$scope.carname = "Audi";
});
</script>
</body>
</html>
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}}.