[英]jquery bootstrap 4 typescript. using jquery to close modal not working
I am attempting to use jquery to close a bootstrap modal on an angular project in typescript code. 我正在尝试使用jquery在打字稿代码中的角度项目上关闭引导程序模式。
The code: 编码:
function call in html: HTML中的函数调用:
(click)="populaterfpfromsaved(i, createSaved, createProp )"
createSaved
and createProp
are local references on modals createSaved
和createProp
是模态上的本地引用
here they are on the modals: 这里是模态:
<ng-template #createProp let-c="close" let-d="dismiss">
<div class="modal-header">
<h4 class="modal-title">Request For Proposal</h4>
<button type="button" class="close" aria-label="Close" (click)="d('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
.... ....
<ng-template class="mw-100 w-75" #createSaved let-c="close" let-d="dismiss">
<div class="modal-header">
<h4 class="modal-title">Saved RFPs</h4>
<button type="button" class="close" aria-label="Close" (click)="d('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body table-responsive">
<table class="table table-hover">
<thead>
.... ....
and the code in my typescript 还有我的打字稿中的代码
populaterfpfromsaved(index, create, prop){
console.log('it fired to open the rfp modal');
const scoperfp = this.savedrfps[index];
this.savedevent.name = scoperfp.eventname;
this.savedevent.date = scoperfp.datename;
this.savedevent.programdate = scoperfp.datevalue;
this.savedevent.dateflex = scoperfp.dateflex;
this.savedevent.eventpurpose = scoperfp.eventpurpose;
this.savedevent.starttime = scoperfp.startime;
this.savedevent.starttimeflex = scoperfp.starttimeflex;
this.savedevent.endtime = scoperfp.endtime;
this.savedevent.endtimeflex = scoperfp.endtimeflex;
this.savedevent.headcount = scoperfp.headcount;
this.savedevent.eventdetails = scoperfp.eventdetails;
(<any>jQuery(create)).modal('hide');
(<any>jQuery(prop)).modal('show');
}
but the modals do not change. 但模态不会改变。
Is there something I haven't set up right 有没有我没设置好的东西
Change like this it may be work for you let try this once. 像这样进行更改可能对您有用,让我们尝试一次。
change your html file, 更改您的html文件,
<ng-template #createProp let-c="close" let-d="dismiss">
to <div class="modal" id='createProp'></div>
到
<div class="modal" id='createProp'></div>
typescript file, 打字稿文件,
$('#createProp').modal('toggle');
use this above line for wherever you want to close your modal. 在您想关闭模态的任何地方使用此行。
Make sure you have included jquery plugin in your app and declared variable 确保已在应用程序中包含jquery插件并声明了变量
declare var $: any;
angular.cli.json angular.cli.json
"scripts": [ "../node_modules/jquery/dist/jquery.min.js" ]
For more reference, 有关更多参考,
Close Bootstrap Modal https://medium.com/@swarnakishore/how-to-include-and-use-jquery-in-angular-cli-project-592e0fe63176 关闭Bootstrap Modal https://medium.com/@swarnakishore/how-to-include-and-use-jquery-in-angular-cli-project-592e0fe63176
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.