Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/470.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如果数据库属性为空,如何显示默认文本?_Javascript_Angular_Typescript - Fatal编程技术网

Javascript 如果数据库属性为空,如何显示默认文本?

Javascript 如果数据库属性为空,如何显示默认文本?,javascript,angular,typescript,Javascript,Angular,Typescript,我有一个模板。但如果属性为空,我希望有一些默认文本 我现在这样说:您使用的if-else条件是错误的。 您必须使用*ngIf=“result.welcomepopubody==null;else textBlock” 这边走 请参阅下面的代码 <app-modal [modalTitle]="modalTitle" [modalId]="modalId" (closeModal)="close.emit(false)">

我有一个模板。但如果属性为空,我希望有一些默认文本


我现在这样说:

您使用的if-else条件是错误的。 您必须使用
*ngIf=“result.welcomepopubody==null;else textBlock”
这边走

请参阅下面的代码

<app-modal [modalTitle]="modalTitle" [modalId]="modalId" (closeModal)="close.emit(false)">
  <ng-container *ngIf="result; else loading">
    <div class="modal modal-first-view">
      <div *ngIf="result.welcomePopupBody === null; else textBlock" class="modal-text modal-text-first-view">
        <p>
          Welkom, mijn naam is <i class="italics">Roos</i>. Ik ben jouw Virtuele coach en ik ben er om je te te helpen.
        </p>
        <p>
          Als je op onderstaande knop klikt krijg je meer uitleg over je deelname en start je de vragenlijst.
        </p>
      </div>
      <div class="first-view-button-wrap">
        <button (click)="buttonClicked()" type="button" class="button button-double-shadow button-first-view">
             {{ result.welcomePopupButtonText }}
         </button>
      </div>
      <div class="modal-img modal-img-first-view first-view-lady">
        <img [src]="result.welcomePopupImage" alt="Nice lady here to help" />
      </div>

      <!--   <img [src]="result.welcomePopupImage" /> -->
    </div>
  </ng-container>

  <ng-template #textBlock>
    <div [innerHtml]="result.welcomePopupBody"></div>
  </ng-template>
  <ng-template #loading>
    ...Loading
  </ng-template>
</app-modal>


Welkom,mijn naam是Roos。我是虚拟教练,我是教练。

在开始使用vragenlijst的时候,我的名字上写着我的名字。

{{result.welcomepopubuttonext} …装载
您可以直接在div中为正向条件编写模板

<app-modal [modalTitle]="modalTitle" [modalId]="modalId" (closeModal)="close.emit(false)">
    <ng-container *ngIf="result; else loading">
        <div class="modal modal-first-view">

            <div *ngIf="result.welcomePopupBody === null; else textBlock" class="modal-text modal-text-first-view">
                <p>
                    Welkom, mijn naam is <i class="italics">Roos</i>. Ik ben jouw Virtuele coach en ik ben er om je te
                    te helpen.
                </p>
                <p>
                    Als je op onderstaande knop klikt krijg je meer uitleg over je deelname en start je de vragenlijst.
                </p>
            </div>
            <div class="first-view-button-wrap">
                <button (click)="buttonClicked()" type="button" class="button button-double-shadow button-first-view">
          {{ result.welcomePopupButtonText }}
        </button>
            </div>
            <div class="modal-img modal-img-first-view first-view-lady">
                <img [src]="result.welcomePopupImage" alt="Nice lady here to help" />
        </div>

                <!--   <img [src]="result.welcomePopupImage" /> -->
            </div>

    </ng-container>
    <ng-template #textBlock [innerHtml]="result.welcomePopupBody"></ng-template>
    <ng-template #loading>
        ...Loading
    </ng-template>
</app-modal>


Welkom,mijn naam是Roos。我是一名职业教练,我是一名职业教练
特赫本。

在开始使用vragenlijst的时候,我的名字上写着我的名字。

{{result.welcomepopubuttonext} …装载
您还可以提供您的TS文件吗?我添加了interfaceLike。。。当前的方法看起来不错,试着让WelcomePopubody没有值来测试它,并检查HTML代码是否正常工作。您必须更改验证或编写验证的方式。我会将*ngIf更改为-*ngIf=“result.welcomePopupBody==null;然后是defaultTextBody else defaultTextBody”啊,txh,但我只看到这一行:嵌入模板上的任何指令都不使用HTML中的错误属性绑定。确保属性名称拼写为coThank you。很不错的