2

I want to reload the whole page through module.js.

Calling controller

 $state.go("app.home");

 $stateProvider
        .state('app.home', {
            url: '/home',
            data: {
                title: 'About'
            },
            views: {
                "content@app": {
                    templateUrl: 'app/home/views/home.html',
                    controller: 'HomeController'
                }
            }
        })

Now I'm using location.reload for reloading the page. But when I putted location.reoload in HomeController then it is reloading infinite time. That's why I want to reload only first time my page through $stateprovider. I've seen one link How to reload or re-render the entire page using AngularJS. But I'm not able to solve my problem, Because I want to reload the page through Module.js. And $state.reload(); is refresh the state not reload the page.

lin
  • 17,956
  • 4
  • 59
  • 83
Varun Sharma
  • 4,632
  • 13
  • 49
  • 103

1 Answers1

0

You could save a "first time state" in a cookie param to ensure its only reloaded the "first time" to prevent your infinite loop. Put this stuff inside your HomeController controller:

if (!$cookies.get('firsttime')) {
  $cookies.put('firsttime', true);
  $window.location.reload();
}

>> Demo plnkr (The about view gets reloaded on "firsttime")

lin
  • 17,956
  • 4
  • 59
  • 83