Angular 如何通过角度数据表显示实时数据?

Angular 如何通过角度数据表显示实时数据?,angular,angular-datatables,Angular,Angular Datatables,我需要通过角度数据表显示实时数据500到1000个数据将在一分钟内出现,我可以绑定数据,但数据表不工作,我从web套接字获取数据。有什么帮助吗 HTML: }您正在使用普通javascript创建web套接字(例如:ws=newWebSocket(url)) 这种方法的问题是,套接字是在Angular的作用域之外创建的,它不知道这样的套接字正在更改其他Angular组件的状态 因此,在ws.onmessage函数中修改状态后,需要告诉Angular迭代其状态并刷新任何已更改的内容。。。要做到这一

我需要通过角度数据表显示实时数据500到1000个数据将在一分钟内出现,我可以绑定数据,但数据表不工作,我从web套接字获取数据。有什么帮助吗

HTML:


}

您正在使用普通javascript创建web套接字(例如:
ws=newWebSocket(url)

这种方法的问题是,套接字是在Angular的作用域之外创建的,它不知道这样的套接字正在更改其他Angular组件的状态


因此,在
ws.onmessage
函数中修改状态后,需要告诉Angular迭代其状态并刷新任何已更改的内容。。。要做到这一点,您可以应用所描述的方法之一。

websocket是使用Vanilla Javascript创建的吗?或者您是否使用了某种类型的库(当然与angular兼容)?@CarlitosWay使用NodeCan您可以在初始化
ws
变量的地方发布代码吗@CarlitosWay我做到了,注意密码,thanks@CarlitosWay谢谢,我会尝试这段代码并让你不断更新。谢谢你的回复,我如何使用angular 4的应用程序?@guru,在我给你的链接中似乎有很多例子。。。您也可以使用此方法感谢您的回复,i=我将尝试此方法并让您了解最新结果。您好@CarlitosWay我尝试了此方法,我可以查看数据,但表中仍然没有可用数据消息与绑定数据一起显示,有什么帮助吗?效果很好,谢谢您的时间。
        <div class="tab_container">
            <table datatable class="row-border hover" id="detailedreportproduct">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>First name</th>
                        <th>Last name</th>
                    </tr>
                </thead>
                <tbody>
                    <tr  *ngFor="let item of binddatatable">
                        <td>{{binddatatable.id}}</td>
                        <td>{{binddatatable.fname}}</td>
                        <td>{{binddatatable.lname}}</td>
                    </tr>
                   

                </tbody>
            </table>
        </div>
let ws = new WebSocket('ws://192.168.1.254:7851');
ws.onopen= () =>{
  console.log("wsconnected");

  ws.send(JSON.stringify({"MsgID":"ReqData"}));



}


ws.onmessage =(e) =>{


 let Table = $('#detailedreportproduct').DataTable();

  this.dataObj = JSON.parse(e.data)

  this.binddatatable = dataObj;