Angularを1.5から1.6に移行

1.5.6から1.6.1に移行。参考にしたのは

など。

対応箇所

$onInit

初期化のロジックが変更。(bindingsされた変数がconstructor内では利用できなくなった。)
全てのDirectiveとComponentに$onInitを用意し、初期化時の処理を$onInit内に記述。

(この変更は、書き方が統一されるので嬉しい。)

The reasoning behind this change is that it is not idiomatic JavaScript to bind properties to an Object before its constructor has been called ...

$http

$httpのsuccess()error()がなくなった。then()catch()に置き換え。

hash-prefix

hash-prefixが!に変更。

$q

PromiseのRejectionが未処理の場合、警告が出るようになった。

Possibly unhandled rejection:

$uibModalの利用している場合、backdropクリックでモーダルを閉じると警告がでるので、一応以下のように対応。

this.$uibModal
.open({
  templateUrl: 'demo.html',
})
.result.catch(angular.noop);

メモ

errorOnUnhandledRejectionsを利用する。

(この方法だとエラーが捕捉できない)

javascript - Possibly unhandled rejection in Angular 1.6 - Stack Overflow

app.config($qProvider => {
  $qProvider.errorOnUnhandledRejections(false);
})