[英]In Table How to enable and disable Bootstrap Checkboxes with buttons in angular 9?
I am developing a page in an angular.我正在 angular 中开发一个页面。 I am not quite familiar in angular.我对angular不是很熟悉。 I had spent few hours working on it and went through the maximum number of alternate threads regarding this issue.我花了几个小时来解决这个问题,并经历了关于这个问题的最大数量的备用线程。 But couldn't find the solution that I was looking into.但找不到我正在研究的解决方案。
specifically, I want to stress here I am using bootstrap checkboxes.具体来说,我想在这里强调我正在使用引导复选框。 I am not using ng-bootstrap.我没有使用 ng-bootstrap。
Here are the queries I would like to address that are I am having.以下是我想解决的问题。
Below are the details that i had worked for my problem.以下是我为我的问题工作的详细信息。
MyPage.html MyPage.html
<div id='bookstore'>
<table class="table table-responsive table-striped">
<thead class="th-color">
<tr>
<th><input name="select_all_books" type="checkbox" ></th>
<th class="theading">Book ID</th>
<th class="theading">Book Name</th>
<th class="theading">From Date</th>
<th class="theading">To Date</th>
<th class="theading">No of Days</th>
<th class="theading">Apply Date</th>
<th class="theading">Reason</th>
<th class="theading">Book Status</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of bookstore | paginate: { itemsPerPage: pageSize, currentPage: p}">
<td><input type="checkbox" id="rowcheckedbookstore"></td>
<td> {{data.BookId }}</td>
<td>{{ data.BookName }}</td>
<td>{{ data.BookStart | date:'dd-MM-yyyy' }}</td>
<td>{{ data.BookReturn | date:'dd-MM-yyyy' }}</td>
<td>{{ data.BookDays }}</td>
<td>{{ data.ApplyDate}}</td>
<td>{{ data.Reason }}</td>
<td>{{ data.BookStatus}}</td>
</tr>
</tbody>
</table>
</div>
<div class="row paginator">
<div class="col-md-7">
<p> Showing {{ ((p - 1) * pageSize) + 1 }} to {{ pageSize * p }} of {{collectionsize }} </p>
</div>
<div class="col-md-5">
<pagination-controls (pageChange)="p = $event" ></pagination-controls>
</div>
</div>
<div class="container" style="padding-top: 30px;">
<div class="w3-show-inline-block">
<div class="w3-bar">
<button type="submit" id="allobook" class="btn btn-success" [disabled]="true" (click)="allowClick()" style="margin-right: 105px;float: right;">Allow</button>
<button type="submit" id= "rejectbook" class="btn btn-danger" [disabled]="true" (click)="rejectClick()" style="float: right;margin-right: 35px;">Reject</button>
</div>
</div>
</div>
MyPage.ts我的页面.ts
export class MyPageComponent implements OnInit {
page = 1;
pageSize = 10;
p: number = 1;
collectionsize:any;
count: boolean;
bookslistdata:bookslist[];
constructor (private bookslist: BookService) { }
ngOnInit(): void {
this.bookslist.GetBooksData().subscribe(data=>{
this.bookslistdata = data;
this.collectionsize = data.length;
})
}
allowClick(){
alert('approve');
}
rejectClick(){
alert('reject');
}
I am able to disable the buttons on the page load.我能够禁用页面加载上的按钮。 But I am unable to achieve when I try with the checkboxes.但是当我尝试使用复选框时,我无法实现。 I would like to know how can I achieve?我想知道我怎样才能实现?
When the page loads the buttons should be disabled until I click on the checkbox.当页面加载时,按钮应该被禁用,直到我点击复选框。
<input disabled ng-disabled="name == '' || password == ''" type="submit" value="Log in" />
The about code resolved the issue I am having ng-disabled.关于代码解决了我禁用 ng 的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.