好的,我有一个使用ngBootstrap模态框的服务条款模态框。当我按下关闭按钮时,我希望该动作能够确定复选框是否被选中。
这是HTML代码: <ng-template #content let-c="close" let-d="dismiss">
<div class="modal-header">
<h4 class="modal-title">Terms of service.</h4>
<button type="button" class="close" aria-label="Close" (click)="d('Cross
click')">
<span aria-hidden="true">×</span>
</button>
</div>
<button type="button" class="btn btn-success" (click)="c('Close click');
setAccepted(true)" >I accept.</button>
</ng-template>
英译中:
打开模态框的链接和复选框
<div class="custom-control custom-checkbox">
<input *ngIf="accepted" type="checkbox" class="custom-
control-input" id="save-info" required>
<label class="custom-control-label" for="save-info">I have read
</label><a href="javascript:void(0)" (click)="open(content)">
the terms of service</a>.
</div>
在它下面,我有
<p>{{accepted}}</p>
仅供测试。还有 TypeScript。
accepted: boolean = false;
constructor(private modalService: NgbModal) {}
open(content) {
this.modalService.open(content);
}
setAccepted(accepted:boolean){
this.accepted = accepted;
}
我尝试将[(ngModel)], *ngIf, ngModel从我的typescript转换为可接受的布尔值,但似乎没有起作用。
*ngIf="accepted"
是不可能实现的。 - Basavaraj Bhusani