【问题标题】:Modal with List of items带有项目列表的模式
【发布时间】:2018-11-30 17:42:45
【问题描述】:

我正在使用 angular 5 和 spring Boot。我有一个项目列表,我想通过模态显示它们的详细信息。这意味着如果我单击任何项​​目,模式将包含该项目的详细信息。 有人知道如何实现吗?

这是我的清单:

   <mat-card>
      <mat-card-content>
        <div class="form-group">
          <input type="text" style="width: 110px;" placeholder="Search" [(ngModel)]="motCle" aria-label="Search">
          <button  (click)="chercher()"> <span class="glyphicon glyphicon-search"></span></button>
        </div>
        <mat-list>
          <mat-list-item style="color: black;" *ngFor="let p of pans">
            <h3 mat-line >{{p.id}}- {{p.nom}}</h3>
            <span class="clickable" style="color: #cccccc;" class="glyphicon glyphicon-eye-open clickable"></span>
          </mat-list-item>
          <div style="float: left" class="container">
            <ul  style="background-color: transparent;" class="nav nav-pills">
              <li  [ngClass]="{'active':i==currentpage}" *ngFor="let p of pages; let i=index">
                <a style="color: #cccccc;" class="clickable" (click)="gotoPage(i)">{{i}}</a>
              </li>
            </ul>
          </div>
        </mat-list>
      </mat-card-content>
    </mat-card> 

【问题讨论】:

    标签: angular spring-boot


    【解决方案1】:

    带材质对话框:https://material.angular.io/components/dialog/overview

    html

    <mat-list-item style="color: black;" *ngFor="let p of pans">
                <h3 mat-line >{{p.id}}- {{p.nom}}</h3>
                <span (click)="openDetail(p)" class="clickable" style="color: #cccccc;" class="glyphicon glyphicon-eye-open clickable"></span>
              </mat-list-item>
    

    ts

    openDetail(pan) {
       const dialogRef = this.dialog.open(yourDialogComponent, {
          data: { pan: pan},
        });
    }
    

    查看 Angular Material 文档以创建对话框组件

    【讨论】:

    • 我想将它添加到其他组件中,而不是作为 dialog.ts !如何添加它?例如在 users.component.ts 中?我的意思是在包含用户列表脚本的同一个文件中。
    猜你喜欢
    • 2021-03-29
    • 2010-11-17
    • 2020-04-15
    • 1970-01-01
    • 2013-07-22
    • 1970-01-01
    • 2014-04-24
    • 2011-05-18
    • 2022-01-19
    相关资源
    最近更新 更多