AngularJS 2.0 officially announced in October, 2015. Today, we will discuss about one of the main feature of AngularJS. AngularJS community wanted to remove the $scope objects completely. So before going further, let us discuss how we can use AngularJS without $scope objects.
So, if you want to write an angular controller without $scope, then here's the code:
- var angApp = angular.module('angApp',[]);
- angApp.controller('testController', ['$http', function ($http) {
- var self = this;
- self.name ='Hello';
- self.btnClick=function(){
- self.name ='Hello! Button Clicked';
- }
- }]);
Now, we need to create a HTML file and link this controller to that html file. The following is the html file code:
- <html>
- <head>
- </head>
- <body data-ng-app="angApp" data-ng-controller="testController as model">
- <div>
- {{model.name}}
- </br>
- <input type="button" value="Click" data-ng-click="model.btnClick();"/>
- </div>
- </html>
- It communicate between the controller and view.
- It sends or receives data between the controller and view.
- Pass actions to the view from the controller.
- When the $scope object is modified, view automatically changes. Also when user make changes in the View, $scope objects automatically changes.

Sr KarthigaPosted Apr 19, 2016, 11:00 PM
Nice explanation
Mohsin AzamPosted Jan 13, 2016, 1:46 PM
nice
Ehsan SajjadPosted Jan 13, 2016, 10:38 AM
good one
Muhammad Aqib ShehzadPosted Jan 5, 2016, 7:42 AM
Nice one Dear
Akash VarshneyPosted Jan 4, 2016, 5:38 AM
@debasis Saha . Nice article how we can diff between normal variable and scope in that case
Santhakumar MunuswamyPosted Jan 2, 2016, 1:52 AM
Thanks for nice share
Ankur MistryPosted Jan 1, 2016, 10:54 AM
good one