Skip to content

Instantly share code, notes, and snippets.

@djabif
Last active March 20, 2023 13:46
Show Gist options
  • Save djabif/cf2d63cf11a17bf16e5bf80e13c3f730 to your computer and use it in GitHub Desktop.
Save djabif/cf2d63cf11a17bf16e5bf80e13c3f730 to your computer and use it in GitHub Desktop.
Angular Components Challenge - service with dummy data
import { Injectable } from '@angular/core';
import { CardItem } from 'src/app/shared/card-helpers/card-item.model';
import { PostCardComponent } from 'src/app/shared/card-templates/post-card/post-card.component';
import { ProductCardComponent } from 'src/app/shared/card-templates/product-card/product-card.component';
import { QuoteCardComponent } from 'src/app/shared/card-templates/quote-card/quote-card.component';
@Injectable()
export class HomeService {
public getItems(): CardItem[] {
return [
new CardItem(ProductCardComponent, {
title: 'Money plant',
description:
'It is considered as a lucky plant which brings wealth, health, prosperity and happiness in the house.',
image:
'https://img.iproperty.com.my/angel/750x1000-fit/wp-content/uploads/sites/2/2021/01/money-plant.jpg',
price: 29,
}),
new CardItem(PostCardComponent, {
title: 'Best indoor plants',
author: 'Dayana Jabif',
description: `Discover the best 10 indoor plants to add color and interest to every room with our easy-to-follow guide.
Full of expert tips as to which house plants will survive best in your home,
you can banish any worries of green fingered failures for good.`,
publishedDate: new Date('05-20-2022'),
}),
new CardItem(QuoteCardComponent, {
author: 'Marcus Tullius Cicero',
description: `If you have a garden and a library, you have everything you need.`,
}),
new CardItem(ProductCardComponent, {
title: 'Grey Pot',
description:
'Give your plants and home a facelift with this ceramic plant pot.',
image:
'https://www.ikea.com/us/en/images/products/persillade-plant-pot-dark-gray__0439713_pe592235_s5.jpg?f=xl',
price: 22,
}),
new CardItem(QuoteCardComponent, {
author: 'Walter Hagen',
description: `You’re only here for a short visit. Don’t hurry, don’t worry. And be sure to smell the flowers along the way.`,
}),
new CardItem(QuoteCardComponent, {
author: ' Audrey Hepburn',
description: `To plant a garden is to believe in tomorrow.`,
}),
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment