[英]how to collapse a table using bootstrap and angular 7
I have created a simple form which have some details, and i am storing all the values entered using local storage of angular. 我创建了一个简单的表单,其中包含一些细节,并且我存储了使用局部存储角度输入的所有值。 Now i want to print all the values in a table and that table should be collapsible. 现在我想打印表中的所有值,该表应该是可折叠的。 I am not able to collapse the table. 我无法折叠桌子。 Please help me rectifying what i am doing wrong. 请帮我纠正我做错的事。
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<div class="row">
<div class="col-md-6 login-container">
<h2 style="margin: auto">User Information</h2>
<form [formGroup]="userForm" (ngSubmit)="onSubmit()">
<div class="form-group">
<label for="username">Username :</label>
<input type="text" class="form-control" formControlName="username" id="username" autocomplete="on">
<div class="error" *ngIf="userForm.controls['username'].hasError('required') && userForm.controls['username'].touched">
UserName is required
</div>
</div>
<div class="form-group">
<label for="cty">City</label>
<select class="form-control" id="city" formControlName="city">
<option *ngFor="let cty of city" [value]="cty.name">{{cty.name}}</option>
</select>
<div class="error" *ngIf="userForm.controls['city'].hasError('required') && userForm.controls['city'].touched">
City is required
</div>
</div>
<div class="form-group">
<label for="mblNo">Mobile Numer :</label>
<input type="mobileNumber" class="form-control" formControlName="mobileNumber" id="mobileNumber" autocomplete="on">
<div class="error" *ngIf="userForm.controls['mobileNumber'].hasError('required') && userForm.controls['mobileNumber'].touched">
mobileNumber is required
</div>
<p *ngIf="mobileNumber.errors?.minlength">mobileNumber should be atleast 10 digits</p>
</div>
<div class="form-group">
<label>
<input type="radio" value="Male" formControlName="gender">
<span>male</span>
</label>
<label>
<input type="radio" value="Female" formControlName="gender">
<span>female</span>
</label>
<div class="error" *ngIf="userForm.controls['gender'].hasError('required') && userForm.controls['gender'].touched">
Gender is required
</div>
</div>
<br>
<button class="btn btn-success" [disabled]="userForm.invalid">Submit</button>
<div *ngIf="invalidLogin" class="error">
<div>Invalid credentials.</div>
</div><br>
<!-- <a data-toggle="collapse" href="#collapseExample">Collapsible panel</a> -->
<button class="btn btn-info" type="button" data-toggle="collapse" data-target=".collapseExample">
Show
</button>
<div class="collapse collapseExample">
<table class="col-lg-12" >
<tbody>
<tr>
<th>Name</th>
<th>City</th>
<th>Mobile Number</th>
<th>Gender</th>
</tr>
<tr *ngFor="let item of finalData">
<td>{{item.username}}</td>
<td>{{item.city}}</td>
<td>{{item.mobileNumber}}</td>
<td>{{item.gender}}</td>
</tr>
</tbody>
</table>
</div>
</form>
</div>
</div>
This is my entire html code, it is still not working for me. 这是我的整个HTML代码,它仍然不适合我。 I am not understanding what i am missing. 我不明白我错过了什么。
On clicking show button, nothing comes on my screen. 单击“显示”按钮时,屏幕上没有任何内容。 Attaching the screenshot too 也附上截图
您可以使用'ng-boostrap'组件https://ng-bootstrap.github.io/#/components/collapse/examples
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.