Answer the question
In order to leave comments, you need to log in
What is the correct way to migrate to another version of AngularJS?
Hello!
I want to migrate in my application from 1.5 to 1.6 version.
Are there any automatic tools?
And what is better to do first: update the AngularJS version itself and then the code, or vice versa?
Are there any pitfalls?
Thank you!
Answer the question
In order to leave comments, you need to log in
there are no big pitfalls. here is what I added from version 1.5.8
$qProvider.errorOnUnhandledRejections(false);//for fix 4 errors in angular 1.6
$compileProvider.commentDirectivesEnabled(false);//for angular 1.6
$compileProvider.cssClassDirectivesEnabled(false);// надо сначала удалить директиву ui-view в классе
$compileProvider.preAssignBindingsEnabled(true); //todo for angular 1.6
You need to carefully read
https://github.com/angular/angular.js/blob/v1.6.1/...
section Breaking Changes
At least here you can get a rake
Previously, $compileProvider.preAssignBindingsEnabled was set to true by default. This means bindings were pre-assigned in component constructors. In Angular 1.5+ the place to put the initialization logic relying on bindings being present is the controller $onInit method.
To migrate follow the example below:
Before:
angular.module('myApp', [])
.component('myComponent', {
bindings: {value: '<'},
controller: function() {
this.doubleValue = this.value * 2;
}
});
angular.module('myApp', [])
.component('myComponent', {
bindings: {value: '<'},
controller: function() {
this.$onInit = function() {
this.doubleValue = this.value * 2;
};
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question