1. Question:What is scope in AngularJS? 

    Answer
    Scope is a JavaScript object that refers to the application model. It acts as a context for evaluating angular expressions. Basically, it acts as glue between controller and view.
    
    Controller<------> $Scope <------> View
    
    Scopes are hierarchical in nature and follow the DOM structure of your AngularJS app. AngularJS has two scope objects: $rootScope and $scope.

    1. Report
  2. Question:What is $scope and $rootScope? 

    Answer
    $scope - A $scope is a JavaScript object which is used for communication between controller and view. Basically, $scope binds a view (DOM element) to the model and functions defined in a controller.
    
    $rootScope - The $rootScope is the top-most scope. An app can have only one $rootScope which will be shared among all the components of an app. Hence it acts like a global variable. All other $scopes are children of the $rootScope.

    1. Report
  3. Question:What is Controller in AngularJS? 

    Answer
    The controller defines the actual behavior of your app. It contains business logic for the view and connects the model to view with the help of $scope. A controller is associated with a HTML element with the ng-controller directive.

    1. Report
Copyright © 2024. Powered by Intellect Software Ltd