簡體   English   中英

從管道將圖像插入到“背景圖像”中

[英]insert image in a 'background-image' from a pipe

我的 html 文檔中有以下代碼:

<div *ngFor="let search of this.mySearches; let i = index" class="col-sm-6 col-xs-12">
                  <div class="box">
                    <div class="image img-search-rounded">
                      <img [src]="search.postPath | imagenpost: search.generic_category: search.postImg[0]" alt="image" title="image" id="img-rounded" class="img-responsive img-rounded">
                    </div>
                    <div class="pull-left">
                      <h4>{{search.generic_category}}<i class="la la-angle-double-right"></i>{{search.generic_type}}</h4>
                      <p><i class="la la-map-marker"></i>{{search.generic_city}}</p>
                      <p><i class="la la-clock-o"></i> {{search.date | date:'medium'}}</p>
                      <p><i class="la la-circle"></i> Get email notifications</p>
                    </div>
                    <div class="pull-right">
                      <button type="button" [routerLink]="search.url">View</button>
                      <button type="button" (click)="removeMySearch(search._id)">Delete</button>
                    </div>
                  </div>
                </div>

但我得到了這個而不是圖像:

錯誤圖像

我怎么能渲染圖像?

目前還不清楚你想要做什么。 似乎您正在嘗試使用三元運算符進行 OR 運算,但您錯過了 else 部分。

條件應該是這樣的

<div [ngStyle]="{'background-color':person.country === 'UK' ? 'green'
> : 'red' }"></<div>

此處閱讀有關示例的更多信息

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM