K
K
klinnov2017-01-25 13:24:08
JavaScript
klinnov, 2017-01-25 13:24:08

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

2 answer(s)
O
ozknemoy, 2017-01-25
@klinnov

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

in docks everything is described what for it. plus my comments

V
Vladimir, 2017-01-26
@Casufi

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;
    }
  });

after:
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 question

Ask a Question

731 491 924 answers to any question