简体   繁体   English

如何在不刷新的情况下更新 angular 页面?

[英]How to update angular page without refreshing?

I am using Angular 7 and there is main page.我正在使用 Angular 7 并且有主页。

The main page has lots of buttons and the button has progress bar like this:主页有很多按钮,按钮有这样的进度条:

在此处输入图像描述

Once working with the component and the component is closed, the button's progress bar should update.使用组件并关闭组件后,按钮的进度条应更新。

In here, MatDialog is working well for the update function.在这里,MatDialog 适用于更新 function。

However, the new tab one doesn't update.但是,新标签页不会更新。

The other code is exactly same except the closing function.除了关闭 function 之外,其他代码完全相同。

MatDialog(Working): MatDialog(工作):

dialogRef.afterClosed().subscribe((result) => {         
            this.updateProgress(...).catch((error) => { console.log(error); });
}); 

New Tab(Not Working):新标签(不工作):

windowRef.addEventListener('beforeunload', () => {
            this.updateProgress(...).catch((error) => { console.log(error); });                
});

I found the button's progress bar is update when I click on the other button.当我单击另一个按钮时,我发现按钮的进度条正在更新。 I think any event happened after closing new tab.我认为关闭新标签后会发生任何事件。

In this case how can I make event for main page without refreshing whole page?在这种情况下,如何在不刷新整个页面的情况下为主页制作事件?

Please give me some advise.请给我一些建议。

I appreciate you in advance and sorry for bad explanation.我提前感谢您,并对不好的解释感到抱歉。

You could consider implementing a pub/sub for your app.您可以考虑为您的应用实现发布/订阅。 This will allow you to push events to all active clients and let them know they need to pull an update from the server.这将允许您将事件推送到所有活动客户端,并让他们知道他们需要从服务器中提取更新。

Here is a link to a popular client: https://socket.io这是一个流行客户端的链接: https://socket.io

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在不刷新整个页面的情况下更新组件 - Angular - How to Update a Component without refreshing full page - Angular 在 angular 中无法在不刷新整个页面的情况下更新 Navbar 组件 - Unable to update Navbar component without refreshing the entire page in angular 如何在不刷新组件属性更改的完整页面的情况下更新DOM - How to Update a DOM without refreshing full page on Component property changes 如何在不刷新页面的情况下自动更新离子列表上的数据 - How to auto update data on ionic list without refreshing the page 如何在不刷新页面的情况下更新视图中显示的数据? - How to update displayed data in the view, without refreshing the page? 如何在angular8中不刷新页面的情况下更改url的值 - How to change the value of the url without refreshing the page in angular8 如何在不刷新整个页面的情况下从视图中刷新数据? 有角度的 - How to refresh data from view without refreshing the whole page? angular Angular 5-路由页面刷新而不是DOM更新 - Angular 5 - Page refreshing on route instead of DOM update 如何在单击事件时刷新页面视图的一部分而不刷新整个页面? - How to refresh a part of the page view without refreshing the entire page in angular on a click event? 更新本地存储中的值并显示在网页上,无需刷新页面 - Update the value in local storage and display it on web page without refreshing the page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM