When?
First internal migration in May
Final release?
What?
Speed
Template Syntax
<button ng-click="ctrl.add()">Add item</button>
<ul>
<li ng-repeat="item in ctrl.items">
{{item.name}}
</li>
</ul>
Template Syntax
<button (click)="add()">Add item</button>
<ul>
<li *foreach="#item in items"">
{{item.name}}
</li>
</ul>
Components
angular.module('app')
.directive('myComponent', function () {
return {
template: '<li ng-if="true">{{ctrl.bigName}}</li>',
controllerAs: 'ctrl',
scope: {
name: '@'
},
controller: function ($scope, $element, $attrs) {
this.bigName = $scope.name;
}
};
});
Components
@Component({
selector: 'my-component',
bind: {
name: 'name'
}
})
@Template({
inline: '<li [if]="true">{{bigName}}</li>',
directives: [If]
})
class MyComponentController {
constructor() {
this.bigName = this.name.toUpperCase();
}
}
Components
function MyComponentController() {
this.bigName = this.name.toUpperCase();
}
MyComponentController.annotations = [
new Component({
selector: 'my-component',
bind: { name: 'name' }
}),
new Template({
inline: '<li [if]="true">{{bigName}}</li>',
directives: [If]
})
];
TypeScript 1.5
DI
Other features
How?
Classes
Classes for everything
TypeScript?
Controllers
Avoid ng-controller
Keep 'angular-isms' out.
Services like $timeout & $q are OK.
bindToController
angular.module('app').directive(function () {
return {
scope: true, // or {}
bindToController: {
name: '@'
}
};
});
Small directives
Upcoming
e.g. angular.module('app').component()
Mix & Match
A1
A1
A2
A1
A2
A1
A2
A1
Angular.io
ng-conf