Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的页面上有很多过滤器。我正在使用 $location.search 将搜索参数保存在哈希中。但是 Angular 在我想阻止的每个搜索参数更改上创建新的控制器实例。
我不想在每个 $location.search() 调用上创建新的控制器实例。
创建路由定义时设置reloadOnSearch为false
reloadOnSearch
false
angular.module('ngView', ['$routeProvider', function(routeProvider) { routeProvider.when('/my-path', { templateUrl: 'my-template.html', controller: 'MyController', reloadOnSearch : false }); }]);