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:
I hereby claim:
To claim this, I am signing this object:
// 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', |
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({
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())] + '!'); |
var mutexify = function (fn, lim) { | |
var queue = []; | |
var inProgress = 0; | |
var invokeNext = function () { | |
if (queue.length === 0) { | |
return; | |
} | |
if (inProgress >= lim) { |
<snippet> | |
<content><![CDATA[[ | |
{ | |
id: 1, | |
name: 'Batarang', | |
img: 'http://25.media.tumblr.com/tumblr_l7s7b3PTAt1qzpwi0o1_500.jpg', | |
price: 80 | |
}, | |
{ | |
id: 2, |