I have learned a little bit of Angular, at the front end, and then I wrote a simple example, that is, to display the browser information. The relevant code is as follows, which can run normally. The interface will display the browser information first, and then display the IP address in a few seconds.
</mat-row>
</mat-table>
`,
})
export class ClientInfoComponent implements OnInit {
dataSource: ClientInfoDataSource;
displayedColumns = ["key", "value"];
constructor(private clientInfoService: ClientInfoService) {
}
ngOnInit(): void {
this.dataSource = new ClientInfoDataSource(this.clientInfoService);
}
}
class ClientInfoDataSource implements DataSource<any> {
constructor(private clientInfoService: ClientInfoService) {
}
connect(): Observable<ClientInfo[]> {
return this.clientInfoService.getClientInfo();
}
disconnect(): void {
}
}