日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪(fǎng)問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

SAP Spartacus 的基于outlet 的页面扩展

發(fā)布時(shí)間:2023/12/19 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SAP Spartacus 的基于outlet 的页面扩展 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

outlet 是 SAP Spartacus 提供 partners 一種將 custom UI 插入 Spartacus 標(biāo)準(zhǔn) DOM 的一種手段。

outlets get added for each slot when page templates, slots or components are dynamically rendered.

outlet的label和被包裹的element name屬性一致。

需求:在Spartacus product明細(xì)頁(yè)面(Product detail page, 縮寫(xiě)PDP)里增添邏輯:如果一個(gè)產(chǎn)品的庫(kù)存小于300,顯示“Limited offer”的提示信息,如下圖所示:

下面是具體實(shí)現(xiàn)方法:

新建一個(gè)Outlet Component:

import { Component, OnInit } from '@angular/core'; import { Product, ProductService } from '@spartacus/core'; import { CurrentProductService } from '@spartacus/storefront'; import { Observable } from 'rxjs';@Component({selector: 'app-outlets',templateUrl: './outlets.component.html', }) export class OutletsComponent implements OnInit {hotProduct$: Observable<Product> = this.productService.get('816780');currentProduct$: Observable<Product> = this.currentProductService.getProduct();constructor(private productService: ProductService, private currentProductService: CurrentProductService) { }ngOnInit() {}}

頁(yè)面模板:

<ng-template cxOutletRef="Section1" cxOutletPos="before"><h1>Hot sale</h1><cx-product-list-item*ngIf="hotProduct$ | async as product"[product]="product"></cx-product-list-item> </ng-template><ng-template cxOutletRef="PDP.PRICE" cxOutletPos="before"><h3class="text-danger"*ngIf="(currentProduct$ | async)?.stock.stockLevel < 300">Limited offer!</h3> </ng-template>

在NgModule里,將outlet Component加入到exports區(qū)域里:

import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { OutletsComponent } from './outlets.component'; import { OutletRefModule, ProductListModule } from '@spartacus/storefront';@NgModule({declarations: [OutletsComponent],imports: [CommonModule,OutletRefModule,ProductListModule],exports: [OutletsComponent] }) export class OutletsModule { }

總結(jié)

以上是生活随笔為你收集整理的SAP Spartacus 的基于outlet 的页面扩展的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。