I’ve been using Angular for all of my rapid-prototyping work for almost three years now. I’m very comfortable with the Angular idiom. But there’s one piece of it that I’ve entirely abandoned as bad hygiene and broken functionality (at least when mixed with ‘function statements’): the ‘single-line-define-and-assign’ pattern for variables and functions we want to expose via Angular’s $scope:
$scope.myVar = 12345; $scope.myFunction = function () {/* do stuff */};
Instead, I do it like this:
var myVar = 12345; function myFunction() { /* do stuff */ } $scope.myVar = myVar; $scope.myFunction = myFunction;
<screaming ensues> I know, I know. “Ur doin’ it wrong!” But read on, and scream after.