0

I use ui-roter for my app. I want my page to reload itself when I send a hardRelad parameter.

This is how I go to that state.

$state.go("widget", {"widgetUrl" : url, "hardReload": true});

This is my controller, where I reload when parameter is passed.

This works fine in chrome, but doesn't work on safari and chrome. It reloads home state which is localhost:8080/#

(function(){

  'use strict'

  angular
    .module('myApp')
    .controller('WidgetController', controllerFunction)
  controllerFunction.$inject = ['$window', '$stateParams', '$scope'];

  function controllerFunction($window, $stateParams, $scope) {
    var vm = this;
    $scope.widgetUrl = $stateParams.widgetUrl;
    if($stateParams.hardReload) {
      $window.location.reload();
    }
  }
})();

This is my routing definition

$stateProvider
  .state('home', {
    url: '/',
    templateUrl: 'views/main.html',
    controller: 'MainCtrl as vm'
  })
  .state('widget', {
    url: '/widget/{widgetUrl}',
    params: {
      hardReload: false
    },
    templateUrl: 'views/widget.html',
    controller: 'WidgetController as vm'
  });
fyelci
  • 1,399
  • 2
  • 16
  • 27

1 Answers1

0

I used $locationChangeSuccess this worked. Thanks for your help

$rootScope.$on('$locationChangeSuccess',
  function (event) {
    if(event.currentScope.hardReload) {
      $window.location.reload();
    }
  });
fyelci
  • 1,399
  • 2
  • 16
  • 27