错误 Ngx-Bootstrap 指令模态 Angular 6

Error Ngx-Bootstrap Modal with Directives Angular 6

core.js:1633 ERROR Error: Uncaught (in promise): Error: Template parse errors: There is no directive with "exportAs" set to "bs-modal" ("

]#staticModal="bs-modal" [config]="{backdrop: 'static'}" tabindex="-1" role="dialog" aria-label"): ng:///MobileModule/PerfilConfigComponent.html@1069:34 Can't bind to 'config' since it isn't a known property of 'div'. ("

<input class="text-center form-control"
               formControlName="grupos"
               pInputText
               autocomplete="off"
               type="text"
               appBlur
               [focusRemove]="true"
               placeholder="Informe os grupos de produtos"
               [pTooltip]="perfilHints?.grupos"
               tooltipPosition="top"
               [showDelay]="2000"
               [escape]="false"
               [life]="12000"
               (click)="staticModal.show()"/>

<div class="modal fade" bsModal #staticModal="bs-modal" [config]="{backdrop: 'static'}"
   tabindex="-1" role="dialog" aria-labelledby="dialog-static-name">
   <div class="modal-dialog modal-sm">
      <div class="modal-content">
         <div class="modal-header">
            <h4 id="dialog-static-name" class="modal-title pull-left">Static modal</h4>
            <button type="button" class="close pull-right" aria-label="Close" (click)="staticModal.hide()">
               <span aria-hidden="true">&times;</span>
            </button>
         </div>
      <div class="modal-body">
      This is static modal, backdrop click will not close it.
      Click <b>&times;</b> to close modal.
    </div>
  </div>
</div>

与 ngx-bootstrap 中的示例相同。服务正常。

我找到了问题的解决方案。我必须导入到其他模块 ModalModule。我不知道为什么,因为它是在"app.module"中导入的,与其他人共享导入。只要使用指令就会出现问题。

也许你没有在你的模块中导入 ModalModule 因为 angular 在你的 App:

中没有找到任何指令 bs-module

ModalModule.forRoot() 添加到您的模块。