Top AngularJS Questions and Answers

    1 Votes

51) What are the ways to track the error in AngularJS?

Below are the ways to track the error in AngularJS –
  • $error – This will state the exact error.
  • $dirty - This will indicate if the value is being changed.
  • $invalid – This will indicate in case the value entered is wrong or invalid.
52) How to display the values in tables in AngularJS?
Below is the sample code for showing the data in table –
<table>
<tr>
<th>Product Name</th>
<th>Product Type</th>
</tr>
<tr ng-repeat="product in category.products">
<td>{{ product.name }}</td>
<td>{{ product.type }}</td>
</tr>
</table>
53) How to show and hide a control in AngularJS?

“ng-show” and “ng-hide” directives are being used for showing and hiding the controls respectively.

54) How to use “ng-click” directive in AngularJS?
“ng-click” directive is used for button control and below is the sample code for the same
<p>Total click: {{ totalClicks }}</p></td>
<button ng-click="totalClicks = totalClicks + 1">Click Me!</button>
55) How to embed one HTML page into other in AngularJS?
HTML will not support embedding one HTML page into other. But this can be achieved using following ways –
  • Using Server Side Includes
  • Using Ajax
56) How embedding one HTML page into other can be achieved using AJAX in AngularJS?

Server call can be done to get the HTML page from server side and set that in the InnerHTML of the control.

57) Explain RouteProvider in AngularJS?

RouteProvider is a key service for setting configuration urls and we can map them to coresponsing HTML pages.

58) Explain how routing works in AngularJS?

Routing enables to create different URL for different content in our application. Different content for different URL enables to bookmark the URL of specific content and this is called route and this mechanism is called routing.

59) Explain string interpolation in AngularJS?

In AngularJS compilation, attributes and text matches using interpolation services to check whether they contain any embedded expressions.

60) Explain the difference between compile and link in AngularJS?

  • Compile : This function is used for DOM manipulation and for collecting the directives.
  • Link : This function is used for registering the DOM listeners and instance of DOM manipulation. This will executed only once during template clone.

61) List out the style classes which can be added with ng-model in AngularJS?

Below are the list of CSS classes which can be used for styling –

  • ng- invalid
  • ng-pristine
  • ng- valid
  • ng-dirty

62) How to dynamically disable the button control in AngularJS?

Below is the sample code to disable the button control based on the checkbox selected –

<div ng-app="" ng-init="isDisable=true">
<p>
<button ng-disabled="isDisable">Click Me!</button>
</p>
<p>
<input type="checkbox" ng-model="isDisable"/>Button
</p>
</div>
Page 5 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