Top AngularJS Questions and Answers

    1 Votes

41) How to make Http get request from AngularJS with an example?

From AngularJS we can use “$http” service. Below is the sample code for http get request –

$http.get('/MyURL').
success(function(data, status, headers, config) {
// code here
}).
error(function(data, status, headers, config) {
// code here
});
42) How to make Http Post request from AngularJS with an example?
Below is the sample code for http post request –
$http.post('/ MyURL', {msg:'hello word!'}).
success(function(data, status, headers, config) {
// code here
}).
error(function(data, status, headers, config) {
// code here
});
43) What is Dependency Injection (DI)?

Dependency Injection (DI) is the process of injecting all the dependent objects rather than creating an instance of dependent objects.

44) How Dependency Injection works in AngularJS?

As shown in the below sample code “$scope” and “$http” objects are being injected in angular framework.

module.controller('MyTestController', function ($scope, $http) { 
// injected dependencies 
});

45) Explain validations done in AngularJS?

AngularJS will leverage on HTML 5 validations. Below is the sample code for required field validation.

Product Name :- <input type=text name="ProdName" id="ProdName" required />

46) How we can check for errors for specific field in AngularJS?

Using “$valid” property we can check the validity of the form inside “ng-app” directive.

47) Explain Two-way binding in AngularJS?

“ng-model” is being used for two-way model binding. Whenever any change in the model, view will be updated automatically and vice versa.

Eg:

<input type="text" ng-model="mytestname" />

48) Explain One-way binding in AngularJS?

This type of binding is being introduced in angularJS version – 1.3 and double colon - “::” is used for one-time expression. Below is the example of using it –

Eg : {{:: mytestname }}

49) Give an example of Data binding in AngularJS?

<div ng-app="" ng-init="quantity=10;cost=5" class="ng-scope">
<b>Total Cost: {{cost * quantity}}</b>
</div>

50) List out the form events in AngularJS?

Below are the list of events in AngularJS –

  • ng-dbl-click
  • ng-click
  • ng-mouseup
  • ng-mousedown
  • ng-mouseover
  • ng-mousemove
  • ng-mouseenter
  • ng-keypress etc.
Page 4 of 5

Popular Videos

communication

How to improve your Interview, Salary Negotiation, Communication & Presentation Skills.

Got a tip or Question?
Let us know

Related Articles

HTML/HTML5 Interview Questions and Answers
JQuery Interview Questions and Answers
Javascript Interview Questions and Answers
Top 60+ Node.JS Interview Questions and answers
Top 70 CSS Interview Questions and Answers
React JS Interview Questions and Answers