如何在Angular 6的同一页面上两次显示相同的swagger编辑器

问题描述 投票:0回答:2

我想在Angular 6+的同一个html上两次实现npm swagger-editor-dist中的swagger-editor。我已经在模式中的展开按钮上以及展开按钮下方显示了swagger-editor。但是,它仅在扩展模式中显示摇动,而在其下方的div中不显示。

如何同时显示相同的Swagger?

首页ui-

UI

模态挥手-

swagger in modal

代码-

app.component.html

<div class="form-group">

<i class="fa fa-expand" data-toggle="modal" data-target="#exampleModalCenter">

</i>

<!-- Modal -->
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLongTitle">Swagger of </h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">

<div class="col-12">
<div id="swagger-editorInbox"  style="height:500px">
</div>
</div>

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>


<div class="row"  style="border:solid 1px gray">

<div id="swagger-editorInbox"  style="height:500px"></div>
</div>



</div>

app.component.ts

declare const SwaggerEditorBundle: any

export class swaggerComponent implements OnInit{


editorInbox :any

ngOnInit(){

this.editorInbox = SwaggerEditorBundle({
dom_id: "#swagger_editorInbox"
})

mySwagger = '....//my swagger// ...';

this.editorInbox.specActions.updateSpec(mySwagger);


}


}

我想在Angular 6+的同一个html上两次实现npm swagger-editor-dist中的swagger-editor。我已经在模式中的展开按钮上以及展开下方显示了swagger-editor ...

javascript angular swagger swagger-ui swagger-editor
2个回答
0
投票

创建2个ID。您可能需要执行styling。很难做造型。我建议一次只显示一个。 [仅C0]内容


0
投票

app.component.html

© www.soinside.com 2019 - 2024. All rights reserved.