import { Component } from "@angular/core";
import { MessageService, MenuItem } from "primeng/api";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
providers: [MessageService]
})
export class AppComponent {
cols: any[];
tutorials: Tutorial[];
selectedProduct: Tutorial;
gfg: MenuItem[];
selectedColumns: any[];
constructor(private messageService: MessageService) {}
ngOnInit() {
this.tutorials = [
{
id: 1,
title: "Queue",
category: "Data Structure",
rating: 8
},
{
id: 2,
title: "Circularly LinkedList",
category: "Data Structure",
rating: 1
},
{
id: 3,
title: "Doubly LinkedList",
category: "Data Structure",
rating: 3
},
{
id: 4,
title: "Singly LinkedList",
category: "Data Structure",
rating: 5
},
{
id: 5,
title: "Doubly Ended Queue",
category: "Data Structure",
rating: 10
},
{
id: 6,
title: "Binary Search Tree",
category: "Data Structure",
rating: 2
},
{
id: 7,
title: "Red Black Tree",
category: "Data Structure",
rating: 9
},
{
id: 8,
title: "Breadth First Search",
category: "Graph",
rating: 6
},
{
id: 9,
title: "Floyd's Cycle",
category: "Algorithm",
rating: 7
},
{
id: 10,
title: "Travelling Salesman Problem",
category: "Algorithm",
rating: 4
},
{
id: 11,
title: "Bellman Ford",
category: "Graph",
rating: 8
},
{
id: 12,
title: "KMP Algorithm",
category: "String",
rating: 10
}
];
this.cols = [
{ field: "id", header: "Id" },
{ field: "title", header: "Title" },
{ field: "category", header: "Category" },
{ field: "rating", header: "Rating" }
];
this.gfg = [
{
label: "See this Row",
command: () => this.viewProduct(this.selectedProduct)
},
];
}
viewProduct(product: Tutorial) {
this.messageService.add({
severity: "success",
summary: "Tutorial Selected is: ",
detail: product.title
});
}
}
export interface Tutorial {
id?: number;
title?: string;
category?: string;
rating?: number;
}