Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- id: 1, name: 'Mr.', description: 'dasdad', image: "sada", products: [
- { id: 0, name: 'Milos', description: "sdada", numberOfProduct: 1, image: 'ssad' },
- ]
- },
- {
- id: 2, name: 'Misko', description: 'dasdad', image: "sada", products: [
- { id: 0, name: 'Milos', description: "sdada", numberOfProduct: 1, image: 'ssad' },
- { id: 1, name: 'Somi', description: "haha", numberOfProduct: 1, image: 'haha' }
- ]
- }
- deleteCategory(product: CategoryModel | number): Observable<CategoryModel> {
- const id = typeof product === 'number' ? product : product.id;
- const url = `${this.cateogryUrl}/${id}`;
- return this.http.delete<CategoryModel>(url, httpOptions).pipe(
- catchError(this.handleError<CategoryModel>('deleteProduct'))
- );
- }
- deleteProduct(product: ProductModel | number, index:number): Observable<ProductModel> {
- const idCategory = typeof product === 'number' ? product : product.id;
- const id = index;
- const url = `${this.cateogryUrl}/${id}/${idCategory}`;
- return this.http.delete<ProductModel>(url, httpOptions).pipe(
- catchError(this.handleError<ProductModel>('deleteProduct'))
- );
- }
- deteleProduct(indexCategory: number, indexProduct: number, category: ProductModel) {
- this.dataStorageServiceService.deleteProduct(category,indexProduct).subscribe()
- this.categoryList[indexCategory].products.splice(indexProduct, 1);
- }
- deteleCategory(indexProduct: number, category: CategoryModel) {
- this.dataStorageServiceService.deleteCategory(category).subscribe();
- this.categoryList.splice(indexProduct, 1);
- }
Add Comment
Please, Sign In to add comment