feat: started details page
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { Component, Input, OnDestroy, OnInit } from "@angular/core";
|
||||
import { AfterViewInit, Component, Input, OnDestroy, OnInit } from "@angular/core";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { Subscription } from "rxjs";
|
||||
import { Datum } from "../../services/parsers/rulib/rulib.dto";
|
||||
import { Datum } from "../../services/parsers/rulib/rulib.search.dto";
|
||||
import { SearchService } from "../../services/search.service";
|
||||
|
||||
@Component({
|
||||
@@ -11,11 +12,15 @@ import { SearchService } from "../../services/search.service";
|
||||
styleUrls: ["./home.component.less"],
|
||||
imports: [CommonModule],
|
||||
})
|
||||
export class HomeComponent implements OnInit, OnDestroy {
|
||||
export class HomeComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||
@Input() items: Datum[] = [];
|
||||
private subscription: Subscription = new Subscription();
|
||||
|
||||
constructor(private searchService: SearchService) {}
|
||||
constructor(
|
||||
private searchService: SearchService,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.subscription = this.searchService.currentItemsTerm.subscribe((data) => {
|
||||
@@ -24,12 +29,20 @@ export class HomeComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
getDetails(slug_url: string) {
|
||||
this.searchService.getDetails(slug_url).subscribe((data) => {
|
||||
console.log(data);
|
||||
});
|
||||
this.router.navigate(["/", "detail"], { queryParams: { url: slug_url } });
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.subscription.unsubscribe();
|
||||
}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
this.route.queryParams.subscribe((params) => {
|
||||
const search = params["search"];
|
||||
console.log(params);
|
||||
if (search) {
|
||||
this.searchService.search(search);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user