Created
August 24, 2019 07:24
-
-
Save KaranPato/2bc15a0f7a1e610eec90913fbe5a2efd to your computer and use it in GitHub Desktop.
RecipeListComponent TS file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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