AngularJS Developer Question: Download Questions PDF
Explain me what is scope hierarchy in AngularJS?
Answer:
Scopes are controllers specific. If we define nested controllers then child controller will inherit the scope of its parent controller.
<script>
var mainApp = angular.module("mainApp", []);
mainApp.controller("shapeController", function($scope) {
$scope.message = "In shape controller";
$scope.type = "Shape";
});
mainApp.controller("circleController", function($scope) {
$scope.message = "In circle controller";
});
</script>
<script>
var mainApp = angular.module("mainApp", []);
mainApp.controller("shapeController", function($scope) {
$scope.message = "In shape controller";
$scope.type = "Shape";
});
mainApp.controller("circleController", function($scope) {
$scope.message = "In circle controller";
});
</script>
Download AngularJS Developer Interview Questions And Answers
PDF
Previous Question | Next Question |
What is ng-init directive? | Explain with options on page load how you can initialize a select box? |