Note that there are some explanatory texts on larger screens.

plurals
  1. POAngularJS reloadOnSearch not working
    text
    copied!<p>After performing a search and navigating away i want the user to be able to return to the search page (by hitting back in the browser) and retain the current search parameters. I've come to realize that in order to do this, the pages url must be updated to contain data about the page. With research i found i can update the location using <code>$location</code> and force the page NOT to reload when a change is made by using <code>reloadOnSearch</code> in the routes. However, for some reason when i change the search parameters (<code>url?...</code>) the page in fact does reload. Any idea of how to fix it to prevent reloading?</p> <p><strong>routes.coffee:</strong></p> <pre><code>'use strict' angular.module('app.rc.routes', ['ui.router']) .config ['$stateProvider', '$urlRouterProvider', ($stateProvider, $urlRouterProvider) -&gt; $urlRouterProvider.otherwise '/' $stateProvider ... .state('resource_center.search', url: '/resources/search?term' templateUrl: 'views/rc/search.html' controller: 'SearchCtrl' reloadOnSearch: false ) ... ] </code></pre> <p><strong>search.coffee:</strong></p> <pre><code>'use strict' angular.module('app.rc.controllers').controller 'SearchCtrl', ['$scope', '$state', '$http', '$stateParams', '$location', ($scope, $state, $http, $stateParams, $location) -&gt; $scope.term = $stateParams.term || '' $scope.updateResults = -&gt; console.log "Loading Results" ... $location.search({term: $scope.term}) </code></pre> <p><strong>References:</strong></p> <p>As a reference to how to properly do this, I was using: <a href="https://stackoverflow.com/a/12481175/1382588">https://stackoverflow.com/a/12481175/1382588</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload