What is the recommended (if there is one) future-proof way to write controllers, services and directives in ES6 (using Traceur) so that the most of same code can be used with AngularJS 2.0. I realize that AngularJS 2.0 is still on the drawing board but if I were to start a new app today what style or conventions do I follow so migrating to 2.0 will hopefully be less painful.
Declaring a class and then passing a reference to that class into the controller or service is one point i see:
var app = angular.module('myApp', []);
class MainCtrl {
....
}
class MyService {
....
}
app.controller('MainCtrl', MainCtrl);
app.service('MyService', MyService);
Should the MyService class be moved to a separate file so that potentially in the future I could just export it and have it available to be injected?
What are some other things to keep in mind as I work on a new project using AngularJS (<= 1.3.x) and ES6?
Update After some digging around I wrote a series of blog posts talking about my findings on my blog
this.service = servicein the constructor.