1.5.6から1.6.1に移行。参考にしたのは
- Angular 1.6 is here, this is what you need to know
- https://docs.angularjs.org/guide/migration#migrating-from-1-5-to-1-6
など。
対応箇所
$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); })