8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

angular.js で $location.search を実行した時に画面が更新されるのを防ぐ。

Posted at

$location.search で画面が更新されてしまうのがだいぶあれだったのでないわけないだろうと探したらやっぱりあった。
$routeProvider#when で reloadOnSearch に false を指定すればいいらしい。 http://docs.angularjs.org/api/ng.$routeProvider
このあたりのワードで検索するとよく出てくる locationChangeStart とか routeChangeStart あたりで調べててだいぶはまった。

app.js
angular.module("myApp", [])
  .config(function($routeProvider) {
    $routeProvider
      .when("/", {
        templateUrl: "main.html",
        controller: "MainCtrl",
        reloadOnSearch: false
      });
  });

サンプル

クエリパラメータに状態を保持しつつ画面遷移しない pagination 実装
http://plnkr.co/J6zUcoi7fxLnr4BuYxI8

8
8
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
8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?