How to Use Scope Object in Angularjs?

Scope in Angularjs is an object that acts as a shared context between View and Controllers and enables two layers to exchange information related to the Scope Application Model.

Scope in Angularjs plays the role of joining Controllers with Scheme. It is available for Views and Controllers.

$scope is a built-in object in AngularJS which includes more methods of application data. In this, you can create Properties in the $scope object inside a Controller Function and for this you can specify a Value or Function.

For Example

<!DOCTYPE html>
<html>
<head>
<title>Angular Scope Example</title>
<script src ="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js">
</script>
</head>
<body ng-app="myNgApp">
<h1>AngularJS Scope</h1>
<div ng-controller="myController">
This is Message <br />
<br />
<span ng-bind="message"></span> <br />
<input type="text" ng-model="message" />
</div>
<script>
var ngApp = angular.module('myNgApp', []);
ngApp.controller('myController', function ($scope) {
$scope.message = "Hello Experts PHP!";
});
</script>
</body>
</html>

Output

Angular Scope Example

AngularJS Scope

This is Message