---
title: "What is Scope in AngularJs"  
description: "Hi everyone in this blog I’m explaining about Scope in angularjs.Introduction:Scope is a special javascript object which plays the role of joining con"  
author: "Anonymous User"  
published: 2015-03-25  
updated: 2018-02-22  
canonical: https://www.mindstick.com/blog/10863/what-is-scope-in-angularjs  
category: "angular js"  
tags: ["angularjs scope", "angularjs controller"]  
reading_time: 2 minutes  

---

# What is Scope in AngularJs

Hi everyone in this blog I’m explaining about Scope in [angularjs](https://www.mindstick.com/articles/13081/advantages-disadvantages-of-angularjs-is-that-ideal-for-your-project).

##### Introduction:

##

Scope is a special [javascript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-javascript) object which plays the role of joining [controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc) with the views. Scope contains the model data. In [controllers](https://www.mindstick.com/forum/155773/how-asynchronous-controllers-work-in-asp-dot-net-mvc), model data is accessed via $scope object.

```
<script>    var mainApp = angular.module("mainApp", []);     mainApp.controller("shapeController", function ($scope) {        $scope.message = "In shape controller";        $scope.type = "Shape";    });</script>
```

Following are the important points to be considered in above example.

- v $scope is passed as the first argument to the controller during its constructor definition.
- v $scope.[message](https://www.mindstick.com/forum/12802/show-confirmation-message-yes-or-no-in-asp-dot-net) and $scope.type are the models which are to be used in the HTML page.
- v We've set values to models which will be reflected in the [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) module whose controller is shapeController.
- v We can [define functions](https://www.mindstick.com/interview/33884/how-do-you-define-functions-in-css-and-benefits) as well in $scope.

##### Scope Inheritance:

##

Scope is controllers specific. If we defines 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>
```

Following are the important points to be considered in above example.

- v We've set values to models in shapeController.
- v We've overridden message in child controller circleController. When "message" is used within the module of controller circleController, the overridden message will be used.

##### Example:

##

The following example will [showcase](https://answers.mindstick.com/qa/105858/what-are-the-advantages-of-using-linkedin-showcase-pages-for-niche-content) all the above-mentioned directives.

```
<html><head>    <title>Angular JS Forms</title></head><body>    <h2>AngularJS Sample Application</h2>    <div ng-app="mainApp" ng-controller="shapeController">        <p>{{message}}            <br />            {{type}} </p>        <div ng-controller="circleController">            <p>{{message}}                <br />                {{type}} </p>        </div>        <div ng-controller="squareController">            <p>{{message}}                <br />                {{type}} </p>        </div>    </div>    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></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";        });         mainApp.controller("squareController", function ($scope) {            $scope.message = "In square controller";            $scope.type = "Square";        });     </script></body></html>
```

##### Output:

##

![What is Scope in AngularJs](https://www.mindstick.com/blogs/3c40f8a1-9886-42cb-8a57-2699b78578ae/images/b737f65e-b1e1-4e01-85ad-1c5edf9525f4.png)

---

Original Source: https://www.mindstick.com/blog/10863/what-is-scope-in-angularjs

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
