You are on page 1of 4

VIVA QUESTIONS

1. Q: What is AngularJS, and what are its key features? A: AngularJS is a JavaScript-based
open-source front-end web application framework. Its key features include two-way data binding,
dependency injection, directives, and modularity.
2. Q: Explain the concept of two-way data binding in AngularJS. - A: Two-way data binding
in AngularJS ensures that changes in the user interface automatically update the application's data
model and vice versa, simplifying the synchronization process.
3. Q: What is the purpose of directives in AngularJS? - A: Directives are markers in the DOM
that AngularJS uses to attach behavior to elements. They extend HTML with new attributes and
elements, providing a declarative way to create reusable components.
4. Q: Describe AngularJS modules and their significance. - A: AngularJS modules are
containers for various parts of an application, such as controllers, services, filters, etc. They help
organize and structure the code, promoting modularity.
5. Q: How does dependency injection work in AngularJS? - A: Dependency injection in
AngularJS involves passing dependencies (services) to components (controllers, services, etc.) as
function parameters. It promotes modular and testable code. Program-Specific Concepts:
6. Q: Explain the purpose of the `ng-app` directive in an AngularJS application. - A: The `ng-
app` directive defines the root element of an AngularJS application, marking the boundary where
AngularJS should take control.
7. Q: What role does the `ng-controller` directive play in AngularJS? - A: The `ng-controller`
directive attaches a controller to the view, defining the application behavior for a particular
element.
8. Q: How does the `ng-model` directive facilitate two-way data binding? - A: The `ng-model`
directive binds an input, select, or textarea element to a property on the model. Any changes to the
element are automatically reflected in the model and vice versa.
9. Q: Explain the use of the `ng-repeat` directive in AngularJS. - A: The `ng-repeat` directive
is used for iterating over a collection (such as an array or object) and repeating a set of HTML
elements for each item in the collection.
10. Q: What is the purpose of filters in AngularJS? Provide an example. - A: Filters format the
value of an expression for display. For example, the `uppercase` filter converts a string to
uppercase. (`{{ name | uppercase }}`) AngularJS Calculator Application:
11. Q: How does the calculator application handle basic mathematical operations? - A: The
calculator uses a select element to choose the operation and performs calculations based on user
input.
12. Q: Explain the function of the `ng-click` directive in the calculator program. - A: The `ng-click`
directive triggers a function when the associated HTML element is clicked. In the calculator, it
initiates the calculation.
13. Q: What is the purpose of the `ng-show` directive in the calculator program? - A: The `ng-
show` directive conditionally displays an element based on a Boolean expression. In the calculator,
it shows the result only when it is defined.
14. Q: How does the calculator program handle division by zero? - A: The program checks if
the divisor is zero before performing division and displays an error message if division by zero is
detected.
15. Q: Explain the role of the controller in the calculator application. - A: The controller
handles user input, performs calculations, and manages the display of results in the view.
16. Q: How does the Todo List application allow users to add new tasks? - A: Users can input
a new task in the text field, and clicking the "Add Task" button triggers the `addItem` function,
adding the task to the list.
17. Q: What is the purpose of the `ng-repeat` directive in the Todo List program? - A: The
`ng-repeat` directive iterates over the tasks array, creating a list item for each task and displaying
them in the view.
18. Q: How does the Todo List program handle editing tasks? - A: Clicking the "Edit" button
triggers the `editTask` function, allowing users to update a task by providing a new task name. 19.
Q: Explain the use of the `ng-if` directive in the Todo List program. - A: The `ng-if` directive
conditionally renders the "Edit Task" modal, showing it only when the `editingTaskIndex` is not
null.
20. Q: How is the total number of tasks dynamically displayed in the Todo List program?
A: The expression `{{ tasks.length }}` is used to display the total number of tasks, updating
automatically as tasks are added or removed. AngularJS CRUD Application:
21. Q: What is CRUD, and how does the AngularJS CRUD application implement it? - A:
CRUD stands for Create, Read, Update, and Delete, representing basic operations for managing
data. The AngularJS CRUD application allows users to perform these operations on a list of users.
22. Q: Explain the purpose of the `ng-submit` directive in the CRUD program. - A: The `ng-
submit` directive is used to specify a function to be called when the form is submitted. In the
CRUD program, it triggers the `addUser` function.
23. Q: How does the CRUD application handle editing user details? - A: Clicking the "Edit"
button triggers the `editUser` function, allowing users to update a user's name and age.
24. Q: What role does the `ng-show` directive play in the CRUD application? - A: The `ng-
show` directive is used to conditionally show or hide the "Edit User" modal based on whether the
`editingUser` variable is set.
25. Q: Explain how the CRUD program dynamically displays the total number of users. - A:
The expression `{{ users.length }}` is used to display the total number of users, updating
automatically as users are added or removed.
26. Q: How does the AngularJS Login Form validate the username and password? - A: The
`login` function checks if the entered username and password match predefined values, and it
displays a success or failure message accordingly.
27. Q: What is the purpose of the `ng-model` directive in the Login Form program? - A: The
`ng-model` directive binds the input fields for username and password to variables in the model,
allowing access to user input.
28. Q: Explain the use of the `ng-submit` directive in the Login Form application. - A: The
`ng-submit` directive specifies a function (`login` in this case) to be executed when the login form
is submitted.
29. Q: How does the Login Form program provide feedback to users about the success or
failure of login attempts? - A: The program displays a message using the `ng-show` directive
based on the success or failure of the login attempt.
30. Q: How does the `ng-disabled` directive contribute to the Login Form program? - A: The
`ng-disabled` directive is used to disable the login button if either the username or password field
is empty.
31. Q: How does the AngularJS Weather App fetch weather data from an API? - A: The
application likely uses the `$http` service or a similar method to make an API request and retrieve
weather data.
32. Q: Explain the purpose of the `ng-options` directive in the Weather App program. - A:
The `ng-options` directive is used to dynamically generate `<option>` elements for a `<select>`
based on an array or object, allowing users to select a city.
33. Q: What role does the `ng-change` directive play in the Weather App program? - A: The
`ng-change` directive triggers a function (`getWeather`) when the selected city is changed,
prompting the app to fetch and display weather data for the new city.
34. Q: How does the Weather App handle displaying temperature units in Celsius or
Fahrenheit? - A: The application likely uses a variable or setting to determine the preferred
temperature unit, updating the displayed values accordingly.
35. Q: Explain how the Weather App utilizes the `$scope` object to manage data. - A: The
`$scope` object is used to store and manage data that needs to be accessed in both the controller
and the view, facilitating the two-way data binding in AngularJS.
36. Q: How does the AngularJS Shopping Cart manage product items and quantities? - A:
The shopping cart likely uses an array or object to store product items and their corresponding
quantities.
37. Q: Explain the use of the `ng-repeat` directive in the Shopping Cart program. - A: The
`ng-repeat` directive is used to iterate over the product items in the shopping cart, dynamically
generating HTML elements for each item.
38. Q: What is the purpose of the `ng-click` directive in the Shopping Cart program? - A: The
`ng-click` directive is used to trigger functions when users interact with elements, such as adding
or removing items from the shopping cart.
39. Q: How does the Shopping Cart program calculate the total cost of items in the cart? - A:
The application likely uses a function that multiplies the quantity of each item by its price and
sums up the total cost.
40. Q: Explain how the Shopping Cart program uses the `ng-model` directive for quantity
input. - A: The `ng-model` directive binds the input field for quantity to a variable in the model,
allowing users to update the quantity of items in the shopping cart.
41. Q: What is the purpose of the `$http` service in AngularJS? - A: The `$http` service is
used to make XML Http Requests or JSONP requests and handle responses. It is commonly used
for fetching data from a server.
42. Q: Explain the concept of AngularJS services. Provide an example. - A: Services in
AngularJS are singletons that perform specific tasks, such as fetching data, logging, etc. An
example is the `$http` service used for making HTTP requests.
43. Q: How does AngularJS handle routing, and what is the significance of the `ng-view`
directive? - A: AngularJS uses the `$routeProvider` service for routing. The `ng-view` directive is
a placeholder where views associated with different routes are displayed.
44. Q: Describe the purpose of the `$scope` object in AngularJS. - A: The `$scope` object is the
binding part between the controller and the view. It contains the model data and functions that can
be accessed in both the controller and the view.
45. Q: What is the digest cycle in AngularJS, and how does it relate to two-way data binding?
- A: The digest cycle is the process where AngularJS updates the bindings between the model and
the view. It ensures that changes in one are reflected in the other, maintaining synchronization.
46. Q: Explain the concept of "controller as" syntax in AngularJS. - A: "Controller As" syntax
involves aliasing the controller in the view, providing a clearer and more maintainable way to
reference properties and methods.
47. Q: Why is it recommended to use the "controller as" syntax instead of `$scope` in
AngularJS controllers? - A: Using "controller as" syntax avoids common issues related to
`$scope` inheritance and promotes better code organization and readability.
48. Q: What are AngularJS directives, and how can custom directives be created? - A:
Directives in AngularJS are markers on a DOM element that tell AngularJS to attach a specified
behavior to it. Custom directives can be created using the `directive` function.
49. Q: Discuss the importance of dependency injection in AngularJS. - A: Dependency
injection is crucial in AngularJS as it promotes modular and testable code by allowing components
to request dependencies rather than creating them.
50. Q: What are AngularJS filters, and how can custom filters be implemented? - A: Filters
in AngularJS are used to format data for display. Custom filters can be implemented by registering
a new filter function using the `filter` method of the `angular.module` object.

You might also like