AngularJS OnsenUI 在子页面的 nav.popPage() 上重新加载父页面 [英] AngularJS OnsenUI reload parent page on nav.popPage() in child page
问题描述
我在 ng-init 上调用一个函数,在该页面中,我通过单击按钮将一个新页面推送到导航器的 pageStack.在子页面中,我正在弹出当前页面.现在我想在从页面堆栈中删除子页面时重新加载父页面.
代码如下:
HTML
</ons-navigator><ons-template id="page1.html"><ons-page ng-controller="pageOneController" ng-init="reload()"><on-工具栏><div class="center">第 1 页</div></ons-工具栏><ons-button ng-click="nav.pushPage('page2.html')">推送页面</ons-button></on-page></ons-模板><ons-template id="page2.html"><页面><on-工具栏><div class="center">第 2 页</div></ons-工具栏><ons-button ng-click="nav.popPage();">弹出页面</ons-button></on-page></ons-模板>
AngularJS
module.controller('pageOneController', function(){$scope.reload = function(){console.log('第一页控制器重新加载');}});
更新
一种解决方案是使用重新加载应用
window.location.reload(true);
您可以使用 新的 pageReplace()
随 新的温泉 UI 1.3.0.你可以像这样将它传递给 popPage()
的回调:
$scope.popAndReplace = function() {$scope.nav.popPage({onTransitionEnd : function() {$scope.nav.replacePage('page1.html', { animation : 'none' } );}})};
在这里工作:http://codepen.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 OnsenUI 在子页面的 nav.popPage() 上重新加载父页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!