home page html - 2023 ionic

PHOTO EMBED

Tue Jun 18 2024 07:59:19 GMT+0000 (Coordinated Universal Time)

Saved by @iamkatmakhafola

<ion-header>
  <ion-toolbar color="primary">
    <ion-title>Streaming Providers</ion-title>
  </ion-toolbar>
</ion-header>

<ion-content>
  <ion-list>    
    <div class="card m-3" style="width: 20rem;" *ngFor="let prod of products"> 
      <ion-card>
        <ion-card-header>
          <ion-card-title> {{prod.name}} </ion-card-title>
        </ion-card-header>

        <ion-card-content> {{prod.description}} </ion-card-content>            
                  
        <ion-button (click)="addSubscriptionToCart(prod)">Add to cart</ion-button>
        
      </ion-card>      
    </div>      
  </ion-list>
</ion-content>


//Additional Code
//TS
import { Component, OnInit } from '@angular/core';

import { Subscription } from '../Model/subscriptionModel';
import { FakeSubscriptionDataService } from '../../services/FakeSubscriptionDataService';
import { SubscriptionCartOrganiserService } from '../../services/SubscriptionCartOrganiserService';
import { InfiniteScrollCustomEvent } from '@ionic/angular';

@Component({
  selector: 'app-home',
  templateUrl: './home.page.html',
  styleUrls: ['./home.page.scss'],
})
export class HomePage implements OnInit {
  products : Subscription[] | undefined;
  items = [];
  constructor(private fakeDataProvider : FakeSubscriptionDataService, private cartSubscriptionService : SubscriptionCartOrganiserService) {
    this.products = fakeDataProvider.getOfferedSubscriptions();
  }
  ngOnInit() {}

addSubscriptionToCart(product : Subscription) {
  this.cartSubscriptionService.addProdFromCart(product);
}
}
content_copyCOPY

2023 - Home page html 1.2 In the “home.page.html”: a. The home page should have a title – “Streaming Providers” using the ion-header component. b. The five streaming service names and descriptions should be called using interpolation coupled with the card component. c. Make use of the add to cart buttons to add a streaming service to the cart.