Tag Archives: Angular.js

Why I’ve stopped doing single-line-define-and-assign on Angular $scope

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.

Continue reading

Tagged , ,

Angular from Scratch: Slides from AngularJS Meetup DC

Thanks to all who attended! Thanks to Leigh Frampton for organizing and to LearningObjects (and Optoro :-)) for hosting. Demo files available to clone here.

Tagged , , , , , ,

Phat UI & Angular Testing

The world has changed. UI Engineering is 4 realz. Servers have gotten skinny, UI has gotten fat phat.

To fulfill its potential, UI Developers need to learn/use some important lessons that used to be the exclusive domain of Server-side Dev. Automated testing is one of the biggest. Automated testing, in a nutshell, allows you to prevent regressions while you work, particularly when you’re developing on a large codebase and/or a codebase worked on by many people. Often, this is hard. Angular.JS provides tools that make it easy (-er). Continue reading

Tagged , , , , ,