Skip to content

Instantly share code, notes, and snippets.

@KaranPato
Created August 24, 2019 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KaranPato/2bc15a0f7a1e610eec90913fbe5a2efd to your computer and use it in GitHub Desktop.
Save KaranPato/2bc15a0f7a1e610eec90913fbe5a2efd to your computer and use it in GitHub Desktop.
RecipeListComponent TS file.
import { Component, OnInit } from '@angular/core';
import { MainService } from '../../common/services/main.service';
import { HttpErrorResponse } from '@angular/common/http';
@Component({
selector: 'app-recipe-list',
templateUrl: './recipe-list.component.html',
styleUrls: ['./recipe-list.component.css']
})
export class RecipeListComponent implements OnInit {
dataSource: any;
isAdd: boolean = false;
isEdit: boolean = false;
submitted: boolean = false;
model: any;
isLoading: boolean = false;
constructor(private mainService: MainService) { }
ngOnInit() {
this.GetRecipes();
}
GetRecipes() {
this.mainService.GetRecipes().subscribe((data: any) => {
this.dataSource = data.content;
console.log(this.dataSource);
},
(err: HttpErrorResponse) => {
console.log(err);
});
}
DeleteRecepi(Id: number) {
if (Id > 0) {
this.mainService.DeleteRecepi(Id).subscribe((data: any) => {
if (data.isSuccess) {
this.GetRecipes();
alert(data.message);
console.log(data.message);
}
else {
alert(data.message);
console.log(data.message);
}
}, (err: HttpErrorResponse) => {
console.log(err);
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment