在添加用户时,Html表无法刷新,我如何用可观察的方法使它出现问题,我在 register
中有 AccountService
方法< / strong>和 getAllAdmins
在 UsersService
中,并且在管理员List组件中,在 getAllAdmins
上订阅后获取数据/ em>方法
UsersService
export class UsersService {
constructor(private http: HttpClient) { }
HTTP_URL = environment.HTTP_URL;
getAllAdmins(): Observable<any> {
return this.http.get(this.HTTP_URL + 'UserProfile/GetAdmins'));
}
AccountService
export class AccountService {
constructor(private http: HttpClient) { }
HTTP_URL = environment.HTTP_URL;
register(reg: RegisterModel): Observable<RegisterModel> {
return this.http.post<RegisterModel>(this.HTTP_URL + 'ApplicationUser/Register' , reg).pipe();
}
此功能来自AdminsListComponent.ts
getAdmins() {
this.usersService.getAllAdmins().subscribe(list => {
this.admins = list;
});
}