Skip to content

Instantly share code, notes, and snippets.

@Bilkiss
Created January 6, 2022 13:41
Show Gist options
  • Save Bilkiss/392b79d2f6089273a3cdeb1ed3530f8c to your computer and use it in GitHub Desktop.
Save Bilkiss/392b79d2f6089273a3cdeb1ed3530f8c to your computer and use it in GitHub Desktop.
import { Component, OnInit } from '@angular/core';
import { StorageService } from '../../services/storage.service';
@Component({
selector: 'app-list',
templateUrl: './list.component.html',
styleUrls: ['./list.component.scss']
})
export class ListComponent implements OnInit {
productList$ = this.storage.watch('products');
constructor(
public storage: StorageService
) { }
ngOnInit(): void {
}
removeStoreProduct(name: string): void{
let list = this.storage.get('products');
if (!list) {
list = [];
}
list = list.filter( (x: any) => x.name != name);
this.storage.set('products', list);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment