A $scope is a JavaScript object. The $scope working between the DOM elements and controller both. The main role of $scope is to ties the DOM elements that is view to controller. For Example, Just like MVC [Model-View-Controller], The model work between the view and controller and the Model ties the DOM element/view to controller. The AngularJs code for $scope with ng-controller var app = angular.module( "myApp" , []); app.controller( "MyController" , [ '$scope' , '$http' , function (key, val) { console.log(key); console.log(val); }]); app.directive( "myDirective" , function ($http, $parse) { return { link: function ($scope, scope, attrs) { alert($scope); } } }); ...
Angular, React, JavaScript, Java, PHP, SQL, C#, Vue, NodeJs, TypeScript and Interview Questions Answers