如何使用bootstrap和angular 7折叠桌子

时间:2019-04-18 06:33:32

标签: angular twitter-bootstrap-3 bootstrap-4

我创建了一个简单的表单,其中包含一些细节,并且我正在存储使用angular本地存储输入的所有值。现在,我想在表中打印所有值,并且该表应该是可折叠的。我无法折叠桌子。请帮助我纠正我在做错的事情。

   <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>

这是我的整个html代码,对于我来说仍然无效。我不明白我在想什么。

单击“显示”按钮时,我的屏幕上没有任何内容。也附上截图 documentation

1 个答案:

答案 0 :(得分:0)