Skip to content

Instantly share code, notes, and snippets.

View btford's full-sized avatar
🍊

Brian Ford btford

🍊
View GitHub Profile
@btford
btford / chillax.md
Created October 30, 2014 06:59
Why you shouldn't worry so much about migrating with Angular

Several developers asked me about how difficult it will be to migrate Angular 1 to Angular 2. Angular 2 isn't done, so I legitimately have no idea how hard it will be. But there are a few high-level guiding principals in the design of Angular 1 that make adapting to changes like this fairly painless.

Angular 1 was designed so it would have a fairly minimal API surface. Let's look at controllers, since these are the meat of your app. Controllers are just functions that get passed other components as arguments:

MyController ($scope) {
  $scope.list = [];
  
  $scope.addItem = function (name) {
    $scope.list.push({
@btford
btford / shoppingcat.sublime-snippet
Created October 9, 2012 20:47
snippet for header for angular+yeoman shopping demo
<snippet>
<content><![CDATA[[
{
id: 1,
name: 'Batarang',
img: 'http://25.media.tumblr.com/tumblr_l7s7b3PTAt1qzpwi0o1_500.jpg',
price: 80
},
{
id: 2,
var mutexify = function (fn, lim) {
var queue = [];
var inProgress = 0;
var invokeNext = function () {
if (queue.length === 0) {
return;
}
if (inProgress >= lim) {
@btford
btford / friendlify
Created June 25, 2013 21:59
this is why higher order programming was invented
var friendlify = function (fn, log) {
var patsOnTheBack = [
'you are great',
'you\'re the best',
'wow you\'re awesome'
];
log = log || console.log;
return function () {
var args = arguments;
log(patsOnTheBack[Math.floor(patsOnTheBack.length * Math.random())] + '!');

Keybase proof

I hereby claim:

  • I am btford on github.
  • I am btford (https://keybase.io/btford) on keybase.
  • I have a public key ASBKnE92lxKXQUUFxK_4pCe-UJubMKOwjsiPVhk4Oo22mwo

To claim this, I am signing this object:

@btford
btford / example.js
Created October 31, 2014 19:45
bindToController in ng 1.2.x
// this example shows how to write a helper to get something like bindToController
// in angular 1.2.x
// this example is incomplete and mostly meant to illustrate the technique
angular.module('myModule', []).directive('myDir', function () {
return bindToController({
scope: {
foo: '='
},
controller: 'MyController',