What is scope ($scope) in angularjs? How to define/use scope in angularjs?


scope is an object refers to a model can have data and it propagates events. It is a communication between view and controller (in mvc pattern) or view and view model (in mvvm pattern).

Ex:

angular.module('testApp', [])
.controller('TestController', ['$scope', function($scope) {

  $scope.onClick = function() {
   //do something
  };
}]);

No comments:

Post a Comment