第二次打开模态重定向到 404

问题描述

我有一个按钮,点击该按钮会弹出一个模态,该模态包含一个由路由(path: question)加载的组件。当我第一次按下该按钮时,它会弹出一个模态,一切都会好起来,但是当我关闭模态并再次按下该按钮第二次重定向404 页面时。

假设当模式第一次打开时,路线将是 localhost:3000/testing/5kjkf/(test:question) 并且在关闭模式后路线没有改变。从过去的 5 小时开始,我一直在努力解决这个问题。很感谢任何形式的帮助。谢谢。

xyz.component.html

   <button type="button" class="btn btn-primary" (click)="openQuestionsModal(quesModal)"><i class="fa fa-plus"></i>&nbsp;&nbsp;Create Question</button>
          <ng-template #quesModal>
              <div class="modal-content modal-lg">
                  <div class="modal-header">
                      <button type="button" class="close pull-right" aria-label="Close" (click)="modalRef.hide()">
                          <span aria-hidden="true">&times;</span>
                      </button>
                  </div>
                  <div class="modal-body">
                      <router-outlet></router-outlet>
                  </div>
              </div>
          </ng-template>

xyz.component.ts

openQuestionsModal(template) {
  this.modalRef = this.modalService.show(template);
  this.router.navigate([{ outlets: { test: 'question' } }],{queryParams: { testId: this.test._id },relativeto: this.route,skipLocationChange:true });

}

xyz.modules.ts

        { path: '',component: AComponent,outlet: 'test',children:[
        {
            path: 'question',loadChildren: 'app/admin/questions/questions.module#QuestionsModule'
        }
    ]},

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)