te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>javascript - How to set background image image path in Angular 6 - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to set background image image path in Angular 6 - Stack Overflow

programmeradmin4浏览0评论

<!----- home banner   ---->
<div class="home-slider">
  <ngx-slick class="carousel" [config]="slideConfig">
    <div ngxSlickItem *ngFor="let slide of slides" class="slide">
      <div class="banner">
        <img class="img-responsive" src="{{ slide.img }}" alt="" width="100%">
      </div>
    </div>
  </ngx-slick>
</div>

<!----==== 3 content ----==================--->
<div class="dis_content">
  <div class="container">
    <div class="col-md-4 text-center">
      <i class="fa fa-google-wallet " aria-hidden="true"></i>
      <h4>Discount System</h4>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse id feugiat tellus. </p>
    </div>
    <div class="col-md-4 text-center">
      <i class="fa fa-codepen " aria-hidden="true"></i>
      <h4>Free Delivery</h4>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse id feugiat tellus. </p>
    </div>
    <div class="col-md-4 text-center">
      <i class="fa fa-circle-o-notch " aria-hidden="true"></i>
      <h4>Support 24/7</h4>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse id feugiat tellus.</p>
    </div>
  </div>
</div>


<!---======  4 images =============------------>
<div class="ldy-page">
  <div class="container-fluid">
    <div class="col-md-3">
      <div class="ldy1">
      </div>
    </div>
    <div class="col-md-3">
      <div class="ldy1">
      </div>
    </div>
    <div class="col-md-3">
      <div class="ldy1">
      </div>
    </div>
    <div class="col-md-3">
      <div class="ldy1">
      </div>
    </div>
  </div>
</div>

<owl-carousel [options]="{items: 3, dots: false, navigation: false}" <!-- If images array is dynamically changing pass this array to [items] input -->
  [items]="images"
  <!-- classes to be attached along with owl-carousel class -->
  [carouselClasses]="['owl-theme', 'row', 'sliding']">
  <div class="item" *ngFor="let sliding of slidings;let i = index">
    <div class="thumbnail-image" [ngStyle]="{'background': 'url('abc.jpg')no-repeat scroll center center / 80px 80px'}"></div>
  </div>
</owl-carousel>

<!----- home banner   ---->
<div class="home-slider">
  <ngx-slick class="carousel" [config]="slideConfig">
    <div ngxSlickItem *ngFor="let slide of slides" class="slide">
      <div class="banner">
        <img class="img-responsive" src="{{ slide.img }}" alt="" width="100%">
      </div>
    </div>
  </ngx-slick>
</div>

<!----==== 3 content ----==================--->
<div class="dis_content">
  <div class="container">
    <div class="col-md-4 text-center">
      <i class="fa fa-google-wallet " aria-hidden="true"></i>
      <h4>Discount System</h4>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse id feugiat tellus. </p>
    </div>
    <div class="col-md-4 text-center">
      <i class="fa fa-codepen " aria-hidden="true"></i>
      <h4>Free Delivery</h4>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse id feugiat tellus. </p>
    </div>
    <div class="col-md-4 text-center">
      <i class="fa fa-circle-o-notch " aria-hidden="true"></i>
      <h4>Support 24/7</h4>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse id feugiat tellus.</p>
    </div>
  </div>
</div>


<!---======  4 images =============------------>
<div class="ldy-page">
  <div class="container-fluid">
    <div class="col-md-3">
      <div class="ldy1">
      </div>
    </div>
    <div class="col-md-3">
      <div class="ldy1">
      </div>
    </div>
    <div class="col-md-3">
      <div class="ldy1">
      </div>
    </div>
    <div class="col-md-3">
      <div class="ldy1">
      </div>
    </div>
  </div>
</div>

<owl-carousel [options]="{items: 3, dots: false, navigation: false}" <!-- If images array is dynamically changing pass this array to [items] input -->
  [items]="images"
  <!-- classes to be attached along with owl-carousel class -->
  [carouselClasses]="['owl-theme', 'row', 'sliding']">
  <div class="item" *ngFor="let sliding of slidings;let i = index">
    <div class="thumbnail-image" [ngStyle]="{'background': 'url('abc.jpg')no-repeat scroll center center / 80px 80px'}"></div>
  </div>
</owl-carousel>

How to set the image and background image path in my page? I set the image on home.ponents.ts file. How to set the background image and image path in Angular 6?

[{'background': 'url('abc.jpg')no-repeat scroll center center / 80px 80px'}] in ng:///AppModule/HomeComponent.html@73:38 (" class="item" *ngFor="let sliding of slidings;let i = index">
Share Improve this question edited Jul 19, 2018 at 22:41 Rick 4,1269 gold badges27 silver badges37 bronze badges asked Jul 19, 2018 at 11:26 BalaBala 471 gold badge1 silver badge3 bronze badges 1
  • do u use angular 6 or angularjs?? – לבני מלכה Commented Jul 19, 2018 at 11:27
Add a ment  | 

2 Answers 2

Reset to default 5

use it to wantet selector

[style.backgroundImage]="'url('+ imagSource +')'"

in css:

.item{
    background-position: center;
    background-repeat: no-repeat;
    .
    .
    .
}

Below answer worked for angular 6.

In app.ponent.css

    .image{
         height:40em; 
         background-size:cover;
         width:auto;
         background-image:url('copied image address');
         background-position:50% 50%;
       }

Also in app.ponent.html simply add as below

<div class="image">
Your content
</div>

This way I was able to set background image in Angular 6.

发布评论

评论列表(0)

  1. 暂无评论