I recently started to work with AngularJS and got the hang of the basics for it, but in the examples I've seen around, I came to find two different approaches in them.
Making the variables and functions private:
function myController(){
var controller = this;
controller.myVar = 0;
controller.myFunction = function(){...};
}
And making them public through the $scope:
function myController(){
$scope.myVar = myVar;
$scope.myFunction = function(){...}
}
I can understand the need to make something private, but to expose variables and functions as public doesn't add up to me since it feel like the Single Responsability Principle is broken in those instances.
Is there a good reason to make something public like that? Are there alternatives to making something public? Or am I worrying too much?