Html 加载对象之前的模式渲染
Html 加载对象之前的模式渲染,html,angular,Html,Angular,this.obj数据在模式窗口加载后填充。那么,如何同步数据和模式 组件 export class DialogComponent { obj:any; showModal(name:String) { if(name!==null) { this.obj=name; $("#myModal").modal('show'); } } hideModal():void { document.getElementById
this.obj
数据在模式窗口加载后填充。那么,如何同步数据和模式
组件
export class DialogComponent {
obj:any;
showModal(name:String) {
if(name!==null) {
this.obj=name;
$("#myModal").modal('show');
}
}
hideModal():void {
document.getElementById('close-modal').click();
}
errorModal() {
$("#errorModal").modal('show');
}
}
this.dialog.showmodel(this.referenceNumber)代码>
dialogComponent.ts
export class DialogComponent {
obj:any;
showModal(name:String) {
if(name!==null) {
this.obj=name;
$("#myModal").modal('show');
}
}
hideModal():void {
document.getElementById('close-modal').click();
}
errorModal() {
$("#errorModal").modal('show');
}
}
dialog.html
<div id="myModal" class="modal fade" role="dialog" >
<div class="modal-dialog ">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div class="modal-body">
<p>Record saved Successfully{{obj}}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
&时代;
记录已成功保存{{obj}
接近
角度方法是通过javascript控制模态的可见性
比如:
<div *ngIf="showModal" id="myModal" class="modal fade" role="dialog" >
<div class="modal-dialog ">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" (click)="showModal=false">×</button>
</div>
<div class="modal-body">
<p>Record saved Successfully{{obj}}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
&时代;
记录已成功保存{{obj}
接近
注意按钮上的事件处理程序
您的.ts文件需要showmodel:boolean属性,如果您使用的是推式更改检测,则按钮单击处理程序将需要运行更改检测
编辑:
是的,不要在Angular中使用jQuery。我推荐这个库。角度方法是通过javascript控制模式的可见性
比如:
<div *ngIf="showModal" id="myModal" class="modal fade" role="dialog" >
<div class="modal-dialog ">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" (click)="showModal=false">×</button>
</div>
<div class="modal-body">
<p>Record saved Successfully{{obj}}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
&时代;
记录已成功保存{{obj}
接近
注意按钮上的事件处理程序
您的.ts文件需要showmodel:boolean属性,如果您使用的是推式更改检测,则按钮单击处理程序将需要运行更改检测
编辑:
是的,不要在Angular中使用jQuery。我推荐图书馆。这种方法不正确。如果您想使用JQuery进行DOM操作,您可能不需要Angular。使用html作为模板,从组件内部控制DOM。这种方法不正确。如果您想使用JQuery进行DOM操作,您可能不需要Angular。使用html作为模板,并从组件中控制DOM。