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({
name: name
done: false
});
};
}
The way you integrate this into Angular app is to register it with a module:
angular.module('myModule', []).controller('MyController', MyController);
But you could also call the function MyController
yourself, then hook up events:
var scope = {};
MyController(scope);
someDom.addEventListener('click', function () {
scope.addItem(myForm.value);
renderList(); // defined elsewhere
});
Even though Angular 2 will probably not have an angular.module
API, it should be easy to adapt much of your code to the new API.
Some frameworks rely on inheriting from specific classes for their models. If you subclass these framework-provided classes, your classes will break whenever the API of the superclass changes. This is a technique that Angular specifically avoids. In Angular, you can use POJOs as models, or you can build up your own classes. Either way, changes in Angular itself will not affect your model's code.
Angular has other such features that reduce needless coupling, but these are just two examples.
It's definitely the non invasiveness of angular which let's me sleep in the night. I'm not really concerned about the lack of controllers and modules in ng2.0 but what makes me a little bit nervous are the transformation of directives to "components". We have lots of directives with complex link functions .What happens with those?