创建后在带有模型的html页面中显示值

凯亚诺什·多塔伊

我需要在html中显示信息。

我的信息有2部分:

第一部分:通过本地传递信息(不发送来自服务器的请求)

第二部分:也许需要发送ID并获取信息并以html形式显示。

当我单击以显示详细信息时,它在html中显示了第一部分,而tow部分为空,这是因为在创建html之后填充模型。

Part two创建html后如何显示模型何时被填充或如何显示Part two?????

这是我的ts代码:

export interface DetailModel {
  commentText: string;
  createdByRefId: number;
  createdDateTimePersian: string;
  createdOnUtc: string;
  createdUserFullName: string;
  id: number;
  likeCount: number;
  parentId: number;
  postId: number;
  postTitle: string;
  published: boolean;
  updatedByRefId: number;
  updatedDateTimePersian: string;
  updatedOnUtc: string;
  updatedUserFullName: string;
}

@Component({
  selector: 'kt-detail-comment',
  templateUrl: './detail-comment.component.html',
  styleUrls: ['./detail-comment.component.scss']
})
export class DetailCommentComponent implements OnInit {


  parentComment: CommentEdit;
  childModel: DetailModel = {} as DetailModel;
  parentModel: DetailModel = {} as DetailModel;

  constructor(
    @Inject(MAT_DIALOG_DATA) public data: CommentDetail,
    private defChange: ChangeDetectorRef,
    private dialogRef: MatDialogRef<DetailCommentComponent>,
    private shredService: SharedService) {
    this.childModel = this.data.data;
    if (this.childModel.parentId != null) {
      this.fetchData(this.data.data.parentId);
    }
  }

  ngOnInit(): void {

  }


  fetchData(id: number): void {
    this.shredService.commentGetOne(id).subscribe(data => {
      this.parentModel = data;
    });
  }

  close(): void {
    this.dialogRef.close();
  }

}

更新:

    <div class=" col-md-12 col-xl-12 col-sm-12 col-xl-12 col-lg-12 p-0">
    <div class="topbar col-md-12 col-xl-12 col-sm-12 col-xl-12 col-lg-12mb-3">
        <span (click)="close()">
            <i class="fas fa-times"></i>
        </span>
        <div class="detail-title">
            <label>جزئیات</label>
        </div>
    </div>
    <div class=" mian-content form-inline content col-md-12 col-xl-12 col-sm-12 col-xl-12 col-lg-12 pt-2 pb-3">
        <div *ngFor="let item of globalModel;let i=index"
            class="form-group justify-content-start col-md-12 col-xl-12 col-sm-12 col-xl-12 col-lg-12 pt-2">
            <div class="col-md-2 col-xl-2 col-lg-2 col-sm-12 col-lg-2">
                <label><strong>{{item.name | translate }} </strong></label>
            </div>
            <div *ngIf="!item.isDate && !item.isBoolean && !item.isImage"
                class="showMore col-md-9 col-xl-9 col-lg-9 col-sm-12 col-lg-9 containtText">
                <label class="lbl form-group col-md-12 col-xl-12 col-sm-12 col-xl-12 col-lg-12 p-0" [id]="'lbl'+i">
                    <div class="spanArea col-md-12 col-xl-12 col-sm-12 col-xl-12 col-lg-12" [id]="'spanArea'+i">
                        {{item.value}}
                    </div>
                    <div (click)="More(i)" [id]="'showMoreBtn'+i"
                        class="showMoreBtn hiddenShowMore text-center col-md-12 col-xl-12 col-sm-12 col-xl-12 col-lg-12 p-3">
                        Read More
                    </div>
                </label>
            </div>
            <div *ngIf="item.isBoolean" class=" col-md-9 col-xl-9 col-lg-9 col-sm-12 col-lg-9 containtText">
                <label class="lbl" *ngIf="item.value && !item.isDate">
                    <span> <i class="fa fa-check-circle ic-green"></i></span>
                </label>
                <label class="lbl" *ngIf="!item.value && !item.isDate">
                    <span> <i class="fa fa-ban ic-red"></i> </span>
                </label>
            </div>
            <div *ngIf="item.isImage" class=" col-md-9 col-xl-9 col-lg-9 col-sm-12 col-lg-9 containtText">
                <label class="lbl" *ngIf="item.value && !item.isDate">
                    <span (click)="openDialog(item.value)" class="show-img-box">
                        <i class="fa fa-search"></i>
                        {{'POST.PREVIEW' | translate}}
                    </span>
                </label>
            </div>
            <div *ngIf="item.isDate" class=" col-md-9 col-xl-9 col-lg-9 col-sm-12 col-lg-9 containtText">
                <label class="lbl"
                    *ngIf="item.isDate && lang!=='fa'"><span>{{item.value | date: 'dd/MM/yyyy hh:mm'}}</span></label>
                <label class="lbl" *ngIf="item.isDate && lang==='fa'"><span>{{ item.value | jalali }}</span> </label>
            </div>
        </div>
    </div>
    <div *ngIf="showMore"
        class="buttonShow form-inline content col-md-12 col-xl-12 col-sm-12 col-xl-12 col-lg-12 pt-2 pb-3">
        <div class="col-md-2 col-xl-2 col-lg-2 col-sm-12 col-lg-2">

        </div>
        <div class="btnShow col-md-9 col-xl-9 col-lg-9 col-sm-12 col-lg-9">
            <button mat-button color="primary" (click)="published()">{{'DIALOG_PREVIEW.SKIP' | translate}}</button>
            <button mat-raised-button color="accent"
                (click)="published()">{{'DIALOG_PREVIEW.PUBLISH' | translate}}</button>
        </div>
    </div>
</div>
法比奥

您可以在共享的部分下方添加一些html,如下所示:

<div *ngIf="parentModel" >
 <!-- Your Part 2 goes here -->
</div>

仅在parentModel有数据时显示

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何在带有页面的QML中显示模型?

来自分类Dev

如何从Phoenix框架中的单独模型中创建带有选项和值的Select标记

来自分类Dev

如何使用Scriplet在HTML页面中显示带有换行符的字符串?

来自分类Dev

带有ajax / jquery请求的html页面中未显示成功消息

来自分类Dev

如何使用Scriplet在HTML页面中显示带有换行符的字符串?

来自分类Dev

在页面顶部显示带有空间的HTML书签链接

来自分类Dev

PyQt:QWhatsThis,显示带有图像的HTML页面

来自分类Dev

在SSRS中显示带有图像的HTML

来自分类Dev

在SSRS中显示带有图像的HTML

来自分类Dev

页面刷新后在选择中显示选定的值

来自分类Dev

在 Django 中显示带有特定标签的页面

来自分类Dev

在带有 CI 的 crud 示例中显示 404 错误页面

来自分类Dev

如何在gatsbyJS中动态创建带有参数的页面?

来自分类Dev

保存后模型没有立即显示在关系中?

来自分类Dev

按键验证后如何在HTML页面中显示结果?

来自分类Dev

在 HTML 页面中单击“保存”后如何显示成功消息

来自分类Dev

Django模型中带有外键的重复值

来自分类Dev

在html页面中显示存储在输入数组中的值

来自分类Dev

Html.DropDownListFor字段未显示视图模型中的值

来自分类Dev

带有标签按钮rtl的页面导航中的html

来自分类Dev

在bash脚本中获取带有javascript元素的HTML页面

来自分类Dev

将带有Javascript的HTML页面刮到Excel中

来自分类Dev

重新加载页面后,如何始终在Django模板中显示模型数据?

来自分类Dev

如何在html页面中显示变量(键)的值?

来自分类Dev

如何在html页面中显示变量(键)的值?

来自分类Dev

LocalStorage 值未显示在其他 html 页面中

来自分类Dev

在Netlogo中创建扩散模型(生化模型:带有活细胞的液体)

来自分类Dev

静态创建的Html表链接字段值单击重定向并在java中的另一个页面中显示那些对应的值

来自分类Dev

带有HTML的HTML不能覆盖移动显示页面的100%宽度

Related 相关文章

  1. 1

    如何在带有页面的QML中显示模型?

  2. 2

    如何从Phoenix框架中的单独模型中创建带有选项和值的Select标记

  3. 3

    如何使用Scriplet在HTML页面中显示带有换行符的字符串?

  4. 4

    带有ajax / jquery请求的html页面中未显示成功消息

  5. 5

    如何使用Scriplet在HTML页面中显示带有换行符的字符串?

  6. 6

    在页面顶部显示带有空间的HTML书签链接

  7. 7

    PyQt:QWhatsThis,显示带有图像的HTML页面

  8. 8

    在SSRS中显示带有图像的HTML

  9. 9

    在SSRS中显示带有图像的HTML

  10. 10

    页面刷新后在选择中显示选定的值

  11. 11

    在 Django 中显示带有特定标签的页面

  12. 12

    在带有 CI 的 crud 示例中显示 404 错误页面

  13. 13

    如何在gatsbyJS中动态创建带有参数的页面?

  14. 14

    保存后模型没有立即显示在关系中?

  15. 15

    按键验证后如何在HTML页面中显示结果?

  16. 16

    在 HTML 页面中单击“保存”后如何显示成功消息

  17. 17

    Django模型中带有外键的重复值

  18. 18

    在html页面中显示存储在输入数组中的值

  19. 19

    Html.DropDownListFor字段未显示视图模型中的值

  20. 20

    带有标签按钮rtl的页面导航中的html

  21. 21

    在bash脚本中获取带有javascript元素的HTML页面

  22. 22

    将带有Javascript的HTML页面刮到Excel中

  23. 23

    重新加载页面后,如何始终在Django模板中显示模型数据?

  24. 24

    如何在html页面中显示变量(键)的值?

  25. 25

    如何在html页面中显示变量(键)的值?

  26. 26

    LocalStorage 值未显示在其他 html 页面中

  27. 27

    在Netlogo中创建扩散模型(生化模型:带有活细胞的液体)

  28. 28

    静态创建的Html表链接字段值单击重定向并在java中的另一个页面中显示那些对应的值

  29. 29

    带有HTML的HTML不能覆盖移动显示页面的100%宽度

热门标签

归档