use of $scope (1)

What is the scope variable in angular js?

The $scope in an AngularJS is a built-in object, which contains application data and methods. You can create properties to a $scope object inside a controller function and assign a value or function to it.

The $scope is the glue between a controller and view (HTML). It transfers data from the controller to view and vice-versa.

Ex:

<body ng-app=”myNgApp”>

<div ng-controller=”myController”>

        Message: <br />

        {{message}}<br />

<span ng-bind=”message”></span><br />

<input type=”text” ng-model=”message” />

</div>

<script>

varngApp = angular.module(‘myNgApp’, []);

ngApp.controller(‘myController’, function ($scope) {

            $scope.message = “Hello World!”;

        });