angular - 刷新页面时未触发 Angular callHooks
问题描述
当我使用F5 按钮或来自地址栏ngOnInit 的指令调用 url 未正确调用时,我遇到了问题。我正在使用调试器查看发生了什么,问题是在 ngOnInit 之后未触发 callHook 。
我正在使用 Angular 9.1.2
这是我的 ngOnInit
ngOnInit(): void {
console.log('fired OnInit');
this.dtOptions = {
pagingType : 'full_numbers',
pageLength : 10
};
this.getCurrentUser();
this.initializeList();
this.resetFormData();
}
我正在使用 Ngx-Soap 作为呼叫数据库,这是我的服务
import { Injectable } from '@angular/core';
import { Client, ISoapMethodResponse, NgxSoapService } from 'ngx-soap';
import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { Document } from '../_models/document.model';
import { User } from '../_models/user.model';
@Injectable({
providedIn: 'root'
})
export class GeneralService {
client : Client;
xmlResponse : string;
jsonResponse : string;
resultLabel : string;
constructor(
private soap : NgxSoapService
) {
this.soap.createClient(environment.wsURL).then(client=>{
client.addSoapHeader({
'tns:ModuleCredential':{
'tns:ModuleAppName':'xxxx',
'tns:ModuleUserName':'xxxx',
'tns:ModulePassword':'xxxx'
}
});
client.addHttpHeader(
'Content-Type','text/xml; charset=utf-8'
);
this.client = client;
})
.catch(err=>console.log('SoapError',err))
}
Login(formData : User) : Observable<ISoapMethodResponse>{
const body = {
data : formData
};
return this.client.call('Login',body)
}
GetCategoryList():Observable<ISoapMethodResponse>{
const body ={
data:null
};
return this.client.call('GetCategoryList',body);
}
解决方案
显示 Chrome DevTools 控制台给你的错误。
推荐阅读
- amazon-web-services - AWS Lambda / API Gateway 不通过编码
- javascript - 如何从 Google Speech to Text API 获得有效响应?
- vba - 如何用大写字母或美元('$')符号分割字符串
- python - 在 Debian 上使用 Python 3 找不到 mkdir 命令
- android - ViewPager2 setCurrentItem 方法抛出错误
- excel - excel 指向许多文件夹中已关闭工作簿的外部链接
- css - 如何在语义 UI 中对齐两个项目?
- node.js - 无法从 Heroku 上的 package.json 从 github 安装 npm 包
- sql-server - 为什么在调试模式下运行父包时,子 SSIS 包的 .dtsx 文件会在 BIDS 中打开?
- python - 使用 Vimeo API 时出现 SSL 上传错误