所以,我有一个在ng6和bs4.x中完成的应用
我从此处安装了angular2 / draggable:Angular Draggable
我在以下示例中使用了模式示例:ngx-bootstrap/modal
如果您向下滚动到:Component#,您将看到下面的示例。
模板:
<button type="button" class="btn btn-primary" (click)="openModalWithComponent()">Create modal with component</button>
组件:
从'@ angular / core'导入{Component,OnInit}; 从'ngx-bootstrap / modal'导入{BsModalService,BsModalRef};
@Component({
selector: 'demo-modal-service-component',
templateUrl: './service-component.html'
})
export class DemoModalServiceFromComponent {
bsModalRef: BsModalRef;
constructor(private modalService: BsModalService) {}
openModalWithComponent() {
const initialState = {
list: [
'Open a modal with component',
'Pass your data',
'Do something else',
'...'
],
title: 'Modal with component'
};
this.bsModalRef = this.modalService.show(ModalContentComponent, {initialState});
this.bsModalRef.content.closeBtnName = 'Close';
}
}
/* This is a component which we pass in modal*/
@Component({
selector: 'modal-content',
template: `
<div class="modal-header">
<h4 class="modal-title pull-left">{{title}}</h4>
<button type="button" class="close pull-right" aria-label="Close" (click)="bsModalRef.hide()">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<ul *ngIf="list.length">
<li *ngFor="let item of list">{{item}}</li>
</ul>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" (click)="bsModalRef.hide()">{{closeBtnName}}</button>
</div>
`
})
export class ModalContentComponent implements OnInit {
title: string;
closeBtnName: string;
list: any[] = [];
constructor(public bsModalRef: BsModalRef) {}
ngOnInit() {
this.list.push('PROFIT!!!');
}
}
可拖动功能确实起作用,但是在我的示例中,会发生以下情况:
最后,这是我的@component({...})
我曾经用上面的代码替换ngx-bootstrap的代码中的基本模式...
请告知...