在Angular中使用ngIf的data-src

时间:2017-06-08 12:24:52

标签: html5 angular

我正在通过Angular上传图片。但是当model.logoUrl为null时,链接代码不会显示200 * 200的演示图像。

<div id="carousel-match-generic" *ngIf="statusType=='Edit'" [ngStyle]="{width: '210px'}">
<div  class="fileupload admin-form fileupload-new" data-provides="fileupload">
   <div class="fileupload-preview thumbnail mb15">
     <img *ngIf="model.logoUrl" src="{{model.logoUrl}}" width="200" alt="holder">
     <img *ngIf="!model.logoUrl" data-src="holder.js/200x200" alt="holder">                                      
   </div>
   <span class="button btn-system btn-file btn-block ph5">                                        
   <span *ngIf="!model.logoUrl">上传LOGO</span>
   <span *ngIf="model.logoUrl">修改LOGO</span>
   <input type="file" name="logoUrl" id="inputImage" (change)="fileChanged($event)">
   </span>
 </div>

结果是

<img _ngcontent-c0="" alt="holder" data-src="holder.js/200x200">

0 个答案:

没有答案