Alright I have a terms of service modal which is an ngBootstrap modal and when I press the button to close that button I want the action that closes the modal define wheter the checkbox is checked or not This is the 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')"
(click)="setAccepted(true)" >I accept.</button>
</ng-template>
the link to open the modal and the checkbox
<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>
And under it I have <p></p>
just for testing
And the typescript
accepted: boolean = false;
constructor(private modalService: NgbModal) {}
open(content) {
this.modalService.open(content);
}
setAccepted(accepted:boolean){
this.accepted = accepted;
}
I tried [(ngModel)], *ngIf, ngModel to the accepted boolean from my typescript but nothing seems to work.
Aucun commentaire:
Enregistrer un commentaire