File
Implements
Metadata
| changeDetection |
ChangeDetectionStrategy.OnPush |
| selector |
cx-checkout-progress-mobile-top |
| templateUrl |
./checkout-progress-mobile-top.component.html |
Index
Properties
|
|
|
Methods
|
|
|
Accessors
|
|
|
|
activeStepIndex$
|
Type : Observable<number>
|
Default value : this.checkoutStepService.activeStepIndex$.pipe(
tap((index) => (this.activeStepIndex = index))
)
|
|
|
|
cart$
|
Type : Observable<Cart>
|
|
|
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { CheckoutStep } from '@spartacus/checkout/root';
import { ActiveCartService, Cart } from '@spartacus/core';
import { BehaviorSubject, Observable } from 'rxjs';
import { tap } from 'rxjs/operators';
import { CheckoutStepService } from '../../../services/checkout-step.service';
@Component({
selector: 'cx-checkout-progress-mobile-top',
templateUrl: './checkout-progress-mobile-top.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CheckoutProgressMobileTopComponent implements OnInit {
private _steps$: BehaviorSubject<CheckoutStep[]> =
this.checkoutStepService.steps$;
constructor(
protected activeCartService: ActiveCartService,
protected checkoutStepService: CheckoutStepService
) {}
cart$: Observable<Cart>;
activeStepIndex: number;
activeStepIndex$: Observable<number> =
this.checkoutStepService.activeStepIndex$.pipe(
tap((index) => (this.activeStepIndex = index))
);
get steps$(): Observable<CheckoutStep[]> {
return this._steps$.asObservable();
}
ngOnInit(): void {
this.cart$ = this.activeCartService.getActive();
}
}
<div *ngIf="(activeStepIndex$ | async) !== undefined">
<div *ngIf="cart$ | async as cart">
<div class="cx-media">
<div class="cx-list-media" *ngIf="cart?.totalItems && cart?.subTotal">
{{ 'cartItems.cartTotal' | cxTranslate: { count: cart.totalItems } }}:
{{ cart.subTotal.formattedValue }}
</div>
<div *ngFor="let step of steps$ | async; let i = index">
<div class="cx-list-media" *ngIf="i < activeStepIndex">
<div>{{ i + 1 }}. {{ step.name | cxTranslate }}</div>
<button
class="btn btn-link"
[routerLink]="{ cxRoute: step.routeName } | cxUrl"
>
{{ 'common.edit' | cxTranslate }}
</button>
</div>
<div class="cx-list-media is-active" *ngIf="i === activeStepIndex">
<div>{{ i + 1 }}. {{ step.name | cxTranslate }}</div>
</div>
</div>
</div>
</div>
</div>
Legend
Html element with directive