在子页面上AngularJS nav.popPage()OnsenUI重载父页面 [英] AngularJS OnsenUI reload parent page on nav.popPage() in child page

查看:1252
本文介绍了在子页面上AngularJS nav.popPage()OnsenUI重载父页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我号召NG-初始化函数,并在该网页,我点击一个按钮推一个新页面的pageStack导航仪。而在子页面,我弹出当前页。现在我想重装父页面时,子页面从页面堆栈中删除。

这里是code:

HTML

 < ONS-VAR航海家=导航页面=page1.html>< / ONS-导航>< ONS-模板ID =page1.html>
    <附件页NG控制器=pageOneControllerNG-的init =重装()>
        < ONS-工具栏>
            < D​​IV CLASS =中心>页面1 LT; / DIV>
        < / ONS-工具栏>
        <附件按钮NG点击=nav.pushPage(page2.html')>按页< /附件按钮>
    < /附件页>
< /插件模板>< ONS-模板ID =page2.html>
    <附件页>
        < ONS-工具栏>
            < D​​IV CLASS =中心>页面2'; / DIV>
        < / ONS-工具栏>
        <附件按钮NG点击=nav.popPage();>流行页面和LT; /附件按钮>
    < /附件页>
< /插件模板>

AngularJS

  module.controller('pageOneController',函数(){
    $ scope.reload =功能(){
        的console.log('第一个控制器重新载入');
    }
});

更新

一个解决方案是使用重新加载应用程序

  window.location.reload(真);


解决方案

您可以使用的新的 pageReplace() 随附的新温泉UI 1.3.0 。你可以把它传递给 popPage的回调()是这样的:

  $ scope.popAndReplace =功能(){
  $ scope.nav.popPage({o​​nTransitionEnd:功能(){
     $ scope.nav.replacePage('page1.html',{动画:'无'});
  }})
};

在这里工作: HTTP://$c$cpen.io/frankdiox/pen/gbJGZw

希望它帮助!

I'm calling a function on ng-init and in that page I'm pushing a new page to the pageStack of navigator on a button click. And in the child page I'm popping the current page. Now I want to reload the parent page when the child page is removed from page stack.

Here is the code:

HTML

<ons-navigator var="nav" page="page1.html">

</ons-navigator>

<ons-template id="page1.html">
    <ons-page ng-controller="pageOneController" ng-init="reload()">
        <ons-toolbar>
            <div class="center">Page 1</div>
        </ons-toolbar>
        <ons-button ng-click="nav.pushPage('page2.html')">Push Page</ons-button>
    </ons-page>
</ons-template>

<ons-template id="page2.html">
    <ons-page>
        <ons-toolbar>
            <div class="center">Page 2</div>
        </ons-toolbar>
        <ons-button ng-click="nav.popPage();">Pop Page</ons-button>
    </ons-page>
</ons-template>

AngularJS

module.controller('pageOneController', function(){
    $scope.reload = function(){
        console.log('Page one controller reloaded');
    }
});

Update

one solution is to reload the app by using

window.location.reload(true);

解决方案

You can use the new pageReplace() that comes with the new Onsen UI 1.3.0. You can pass it to the callback of popPage() like this:

$scope.popAndReplace = function() {
  $scope.nav.popPage({onTransitionEnd : function() {
     $scope.nav.replacePage('page1.html', { animation : 'none' } );
  }})
};

Working here: http://codepen.io/frankdiox/pen/gbJGZw

Hope it helps!

这篇关于在子页面上AngularJS nav.popPage()OnsenUI重载父页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆