LoginSignup
0
0

More than 1 year has passed since last update.

Angular15.2からクラスベースのCanActivateやCanDeactivateが非推奨になった…けれども

Last updated at Posted at 2023-03-09

リリースノート
Class and InjectionToken guards and resolvers are deprecated.
https://github.com/angular/angular/blob/main/CHANGELOG.md#1520-2023-02-22

例えば、以下のように典型的な書き換えが必要
Angular AuthGuard: CanActivate and CanActivateChild are deprecated. How to replace them?
https://stackoverflow.com/questions/75564717/angular-authguard-canactivate-and-canactivatechild-are-deprecated-how-to-repla

これの何が気持ち悪いかというと、DIコンテナからサービスロケーターになったということだ。

AngularチームはDIコンテナ派からサービスロケーター派にくら替えしたという事だろうか。
実際のところ、AngularのテストコードはTestBedにべったり依存する前提になるためいまさらではある。
しかしコンストラクターDIをやめてinject()に依存しなければいけないのは何か気持ちが悪い。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0