LoginSignup
0
0

More than 3 years have passed since last update.

AngularJSでcontrollerが2回呼ばれてしまう

Posted at

メモ書き程度。

概要

考えられるのは以下の2パターンです。
1.router側とview側の両方で記述している
2.UI Routerのバグ 1

今回は後者についてです。
パラメータを受け取ってURLを'/url/:hogehoge'のように指定していると発生する場合があります。
パラメータを指定せずに画面遷移すると$stateParams.hogehogeにundefinedが入ります。
$locationChangeSuccessによって$stateParams.hogehogeに空文字が入った状態で再度呼ばれてしまいます。

最新バージョンでは修正されていますが、古いバージョンでは発生する場合があります。
その場合はバージョンを上げるか、回避策2を使ってください。

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