AngularJS Interview Questions

33. Explain DOM and the BOM?
DOM is the Document Object Model. The view part of the UI. Whatever we are changing in page elements is reflected in the DOM.
BOM is the Browser Object Model, which specificies the global browser objects like window, localstorage, and console.

34. What is Dependency Injection in AngularJS?
It is a software design pattern in which objects are passed as dependencies. It helps us to remove hard coded dependencies and makes dependencies configurable. Using Dependency Injection, we can make components maintainable, reusable and testable.
AngularJS uses dependency with several types
Value
Factory
Service
Provider
Constant

35. How to hide an HTML element via a button click in AngularJS?
Using the ng-hide directive in conjunction with a controller to hide an HTML element on button click.

<div>
<button>Hide me</button>Hey Friends
</div>

function MyCtrl($scope) {
$scope.isHide = false;
$scope.hide = function() {
$scope.isHide = true;
};
}

36. How disable a button depending on a checkbox’s state?
Use the ng-disabled directive and bind its condition to the checkbox’s state.
<label><input type=”checkbox” />Disable Button</label>
<button>Select me</button>

COPY CODE SNIPPET