Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 对话框打开时如何显示信息文本_Javascript_Html_Angular_Typescript_Frontend - Fatal编程技术网

Javascript 对话框打开时如何显示信息文本

Javascript 对话框打开时如何显示信息文本,javascript,html,angular,typescript,frontend,Javascript,Html,Angular,Typescript,Frontend,我有这个“帮助”对话框,由于某些原因,对话框一打开,我的信息文本就不会显示出来。它只在我单击该小节时才开始显示,因此我想知道如何在用户打开对话框时立即显示它。任何建议或帮助都将不胜感激 HTML //单击此按钮将向用户显示每个小节 我想这应该行得通 fetchData = () => { this.HelpService.getHelp().subscribe(res => { this.mappedSections.next(res['res']); cons

我有这个“帮助”对话框,由于某些原因,对话框一打开,我的信息文本就不会显示出来。它只在我单击该小节时才开始显示,因此我想知道如何在用户打开对话框时立即显示它。任何建议或帮助都将不胜感激

HTML

//单击此按钮将向用户显示每个小节

我想这应该行得通

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
      }
    }
  })
}