Php 来自不同组件的角度事件
我试图在注销时销毁会话变量。在我的api.service.ts脚本中调用php脚本。发生此情况的页面正在从app.component.html运行Php 来自不同组件的角度事件,php,angular,typescript,session,service,Php,Angular,Typescript,Session,Service,我试图在注销时销毁会话变量。在我的api.service.ts脚本中调用php脚本。发生此情况的页面正在从app.component.html运行 <button type="button" *ngIf="logoutbtn" class="btn btn-block" (click)="logout()">logout</button> api.service.ts文件包含调用php脚本的
<button type="button" *ngIf="logoutbtn" class="btn btn-block" (click)="logout()">logout</button>
api.service.ts文件包含调用php脚本的代码:
logoutUser(){
return this.httpClient.get<Policy[]>(`${this.PHP_API_SERVER}/api/logout.php`, { withCredentials: true });
}
logoutUser(){
返回this.httpClient.get(`this.PHP\u API\u SERVER}/API/logout.PHP`,{withCredentials:true});
}
我如何从app.component.ts进行通信,并在代码行“close session here”上调用api.service.ts文件中的函数?使用依赖项注入
app.component.ts中的api.service.ts
文件
deleteToken()
方法一样使用它
this.apiService.logoutUser().subscribe( response = > {
console.log("user logged out with api call");
})
我添加了
构造函数(privatedataservice:ApiService)
然后运行this.dataService.logoutUser()代码>但是我没有看到php脚本在另一端被调用。我在服务器中运行了一个错误日志,以查看是否正在调用它。这是正确的方法吗?@ConnorThomas你做对了吗?这是正确的方法。
this.apiService.logoutUser().subscribe( response = > {
console.log("user logged out with api call");
})