Heim  >  Fragen und Antworten  >  Hauptteil

angular.js - $scope.$on不起效果

$scope.$on('$stateChangeSuccess', $scope.doRefresh);

这个函数不起效果,我计划想进入当前页面自动刷新,但是只有第一次点击进入页面才可以执行这个函数,再次点击就不进入了,求解。
PHP中文网PHP中文网2714 Tage vor480

Antworte allen(2)Ich werde antworten

  • ringa_lee

    ringa_lee2017-05-15 17:14:38

    找到解决方案了,我甚至试过在
    <ion-view title="XXX" cache-view="false">这里设置都没有效果

    而要在route里面设置cache为false才有效:

    .state('receipt', {
                    url: '/receipt',
                    cache:'false',
                    templateUrl: 'areas/receipt/receipt.html',
                    controller: "ReceiptCtrl"
                })
                
                这样就可以解决了

    Antwort
    0
  • 世界只因有你

    世界只因有你2017-05-15 17:14:38

    注入$rootScope用$rootScope监听

    Antwort
    0
  • StornierenAntwort