Core Java

What are controllers

You can consider controllers as main driver for model view changes. It is a main part of angular js application and It is javascript functions or objects which actually performs ui operation. It controls data of angularjs applications.

What is $scope?

Scope is an object which is glue between model and view. So if you want to pass data from model to view and view to model, it is done through scopes object.

How controllers and scope are related?

Actually controllers passes scope object as constructor parameter and initialise model values and functions. Please don’t worry if it sounds very confusing, once we see simple example, you will be able to relate.
var app = angular.module(‘myApp’, []);
app.controller(‘java2blogContoller’, function($scope) {
    $scope.myJavaMsg = “Hello from myjavablog”;
  
});


Bitnami