♥ 8 AngularJS interview questions & answers

Angular JS and other JavaScript based MVW frameworks are getting so much attention.

Q1. Can you give a big picture of AngularJS highlighting its key components?
A1. A good diagram is worth 1000 words.

angularjs big picture

angularjs big picture

Q2. What is a scope in AngularJS?
A2. scope is an object that refers to the application model. It is the glue between application controller and the view. Both the controllers and directives have reference to the scope, but not with each other. It is an execution context for expressions and arranged in hierarchical structure. Scopes can watch expressions and propagate events.

Q3. Can you explain the concept of scope hierachy? How many scopes can an application have?
A3. Each Angular application has exactly one root scope, but may have several child scopes. The application can have multiple scopes, because child controllers and some directives create new child scopes. When new scopes are created, they are added as children of their parent scope. This creates a hierarchical structure similar to the DOM where they’re attached.

When Angular evaluates a bound variable like say {{firstName}}, it first looks at the scope associated with the given element for the firstName property. If no such property is found, it searches the parent scope and so on until the root scope is reached. In JavaScript this behaviour is known as prototypical inheritance, and child scopes prototypically inherit from their parents. The reverse is not true. I.e. the parent can’t see it’s children’s bound properties.

Q4. How will you display different images based on the status being red, amber, or green?
A4. Use the ng-switch and ng-switch-when directives as shown below.

Q5. How will you initialize a select box with options on page load?
A5. using the ng-init directive.

Q6. How will you show/hide buttons and enable/disable buttons conditionally?
A6. Using the ng-show and ng-disabled directives.

Q7. How will you loop through a collection and list each item?
A7. Using the ng-repeat directive.

Q8. How will you add options to a select box?
A8. Using the ng-options and ng-model directives.


Q9. How will you display inprogress revolving image to indicate that RESTful data is bing loaded?
A9

50+ JavaScript Interview Q&As

50+ JavaScript Interview Questions Answered

If you are a Java developer start with: JavaScript Vs Java interview Q&As.

Print Friendly
The following two tabs change content below.
Arulkumaran Kumaraswamipillai
Mechanical Engineering to Java freelancer since 2003. Published Java/JEE books via Amazon.com in 2005, and sold 35K+ copies. Books are outdated and replaced with this online Java training. join my LinkedIn group.
Arulkumaran Kumaraswamipillai

Mechanical Engineering to Java freelancer since 2003. Published Java/JEE books via Amazon.com in 2005, and sold 35K+ copies. Books are outdated and replaced with this online Java training. join my LinkedIn group.

Posted in AngularJS

800+ Interview Q&As ♥Free|♦FAQ (Mouse Hover for Full Text)

open all | close all

200+ Java FAQs – Memory Joggers

open all | close all

16 Java Key Areas to be a top-notch

open all | close all

80+ Java Tutorials – Step by step

open all | close all

100+ Java Coding Exercises

open all | close all

How good are your "Career Skills"?

open all | close all