Javascript 对话框打开时如何显示信息文本
我有这个“帮助”对话框,由于某些原因,对话框一打开,我的信息文本就不会显示出来。它只在我单击该小节时才开始显示,因此我想知道如何在用户打开对话框时立即显示它。任何建议或帮助都将不胜感激 HTMLJavascript 对话框打开时如何显示信息文本,javascript,html,angular,typescript,frontend,Javascript,Html,Angular,Typescript,Frontend,我有这个“帮助”对话框,由于某些原因,对话框一打开,我的信息文本就不会显示出来。它只在我单击该小节时才开始显示,因此我想知道如何在用户打开对话框时立即显示它。任何建议或帮助都将不胜感激 HTML //单击此按钮将向用户显示每个小节 我想这应该行得通 fetchData = () => { this.HelpService.getHelp().subscribe(res => { this.mappedSections.next(res['res']); cons
//单击此按钮将向用户显示每个小节
我想这应该行得通
fetchData = () => {
this.HelpService.getHelp().subscribe(res => {
this.mappedSections.next(res['res']);
const response = res['res'];
this.clicked(response.id, response.parentId);
let newMappedSection = this.mappedSections.getValue()
for (let i = 0; i < newMappedSection.length; i++) {
const element = newMappedSection[i];
if (element.parentId) {
this.targetSection = element;
break
}
}
})
}
fetchData=()=>{
this.HelpService.getHelp().subscribe(res=>{
this.mappedSections.next(res['res']);
常数响应=res['res'];
单击(response.id,response.parentId);
让newMappedSection=this.mappedSections.getValue()
for(设i=0;i
我猜,一旦您从this.HelpService.getHelp()
获得响应,您就不会初始化targetSectionGroup
。最好用第一个响应数据调用那里的clicked()
函数。@PankajPrakash您好……您能告诉我怎么做吗。谢谢,我不知道为什么它只显示了部分名称,例如“工作区”,就是这样。它没有显示分区名称和所有文本。你知道为什么不显示吗?。谢谢你能分享你的回应结构吗?
mappedSections: BehaviorSubject<any[]> = new BehaviorSubject<any[]>([]);
mappedSecSub = this.mappedSections.asObservable()
targetSection: { id, name, parentId, text };
targetSectionGroup: { id, name, parentId, text }[] = [];
ngOnInit(): void {
this.fetchData();
}
fetchData = () => {
this.HelpService.getHelp().subscribe(res => {
this.mappedSections.next(res['res'])
let newMappedSection = this.mappedSections.getValue()
for (let i = 0; i < newMappedSection.length; i++) {
const element = newMappedSection[i];
if (element.parentId) {
this.targetSection = element;
break
}
}
})
}
clicked(id, parentId) {
this.targetSectionGroup = [];
let data = this.mappedSections.getValue()
for (let i = 0; i < data.length; i++) {
if (data[i].parentId == parentId || data[i].id == parentId) {
this.targetSectionGroup.push(data[i]);
}
if (data[i].id === id) {
this.targetSection = data[i]
}
}
document.querySelector(`#s${id}ss${parentId}`).scrollIntoView({ behavior: 'smooth' })
}
fetchData = () => {
this.HelpService.getHelp().subscribe(res => {
this.mappedSections.next(res['res']);
const response = res['res'];
this.clicked(response.id, response.parentId);
let newMappedSection = this.mappedSections.getValue()
for (let i = 0; i < newMappedSection.length; i++) {
const element = newMappedSection[i];
if (element.parentId) {
this.targetSection = element;
break
}
}
})
}