I googled around a lot, but I can't understand why sometimes people use $scope
in controllers and sometimes else this
.
I mean, what is the difference between:
angular.module('app').controller('MyCtrl', function($scope) {
// this
$scope.s_my_int = 12;
$scope.s_myFunction = function() { alert("I'm a function!") };
$scope.$on('user.login', function () { alert("Welcome!"); }
// and
this.t_my_int = 12;
this.t_myFunction = function() { alert("I'm a function!") };
$scope.$on('user.login', function () { alert("Welcome!"); }
}