마지막으로 나는 완전히 작동시킬 수있는 작은 문제가있었습니다.
데모 :
https://stackblitz.com/edit/ngx-bootstrap-8v1nb5?file=app%2Fapp.component.html
정전기 modal.component.html :
<button type="button" class="btn btn-primary" (click)="staticModal.show()">Static modal</button>
<div class="modal fade" bsModal #staticModal="bs-modal" [config]="{backdrop: true}"
tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<h4 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">×</span>
</button>
</div>
<div class="modal-body">
This is static modal, backdrop click will not close it.
Click <b>×</b> to close modal.
</div>
</div>
</div>
</div>
정전기 modal.component.ts :
import { Component } from '@angular/core';
@Component({
selector: 'static-modal',
templateUrl: './static-modal.component.html',
styleUrls: [ './static-modal.component.css' ]
})
export class StaticModal {
}
정전기 modal.component.css :
app.component.html :
.modal.fade{
display:flex;
top:40%;
justify-content: center;align-items: center;
}
app.module.ts
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { AlertModule } from 'ngx-bootstrap';
import { StaticModal } from './modal-component/static-modal.component';
import { ModalModule } from 'ngx-bootstrap';
@NgModule({
imports: [ BrowserModule, FormsModule, AlertModule.forRoot(),
ModalModule.forRoot() ],
declarations: [StaticModal, AppComponent, ],
bootstrap: [
AppComponent
]
})
export class AppModule { }
마지막으로, 부모 구성 요소
<alert type="success">
<strong>Well done!</strong> You successfully read this important alert message.
</alert>
<static-modal></static-modal>
브라우저 콘솔에서 오류를 확인할 수 있습니까? 또한 재생산 된 plunkr/stackblitz가 도움이 될 것입니다. ngx-bootstrap 용 초보 템플릿 : Plunkr : https://plnkr.co/edit/0NipkZrnckZZROAcnjzB?p=preview StackBlitz : https://stackblitz.com/edit/ngx-bootstrap?file=app%2Fapp.module. TS – IlyaSurmay