Skip to content
Snippets Groups Projects
Commit 7a46b6ae authored by Jérémie BRISON's avatar Jérémie BRISON
Browse files

fix(post) : fix routing lazy

parent b722802a
No related branches found
No related tags found
3 merge requests!103Recette,!102Dev,!89Feat/post details
<div fxLayout="column" *ngIf="post" class="post" [ngClass]="class" fxLayoutGap="12px"> <div fxLayout="column" *ngIf="post" class="post" [ngClass]="class" fxLayoutGap="12px" (click)="showDetails(post)">
<div fxLayout="column" fxLayoutGap="4px"> <div fxLayout="column" fxLayoutGap="4px">
<div fxLayout="row" class="tag" fxLayoutAlign=" center" fxLayoutGap="12px" *ngIf="getIconOfTag(post.tags[0].slug)"> <div fxLayout="row" class="tag" fxLayoutAlign=" center" fxLayoutGap="12px" *ngIf="getIconOfTag(post.tags[0].slug)">
<app-svg-icon <app-svg-icon
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
@import '../../../../assets/scss/typography'; @import '../../../../assets/scss/typography';
.post { .post {
padding: 24px 6px; cursor: pointer;
margin: 24px 6px;
border-bottom: 1px dashed $grey-3; border-bottom: 1px dashed $grey-3;
&.bigNew { &.bigNew {
border: 0; border: 0;
......
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { TagEnum } from '../../enum/tagEnum.enum'; import { TagEnum } from '../../enum/tagEnum.enum';
import { Post } from '../../models/post.model'; import { Post } from '../../models/post.model';
...@@ -11,14 +12,9 @@ export class PostCardComponent implements OnInit { ...@@ -11,14 +12,9 @@ export class PostCardComponent implements OnInit {
@Input() post: Post; @Input() post: Post;
@Input() class: string; @Input() class: string;
test: string; test: string;
constructor() {} constructor(private router: Router) {}
ngOnInit(): void { ngOnInit(): void {}
/*ùif (this.post) {
console.log(this.post);
this.test = this.post.html.replace(/<[^>]*>/g, '');
}*/
}
getIconOfTag(tag: string): string { getIconOfTag(tag: string): string {
switch (tag) { switch (tag) {
...@@ -40,4 +36,7 @@ export class PostCardComponent implements OnInit { ...@@ -40,4 +36,7 @@ export class PostCardComponent implements OnInit {
return null; return null;
} }
} }
public showDetails(post: Post): void {
this.router.navigateByUrl('posts/details/' + post.id);
}
} }
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
@Component({ @Component({
selector: 'app-post-details', selector: 'app-post-details',
templateUrl: './post-details.component.html', templateUrl: './post-details.component.html',
styleUrls: ['./post-details.component.scss'] styleUrls: ['./post-details.component.scss'],
}) })
export class PostDetailsComponent implements OnInit { export class PostDetailsComponent implements OnInit {
constructor(private activatedRoute: ActivatedRoute) {}
constructor() { } postId: string;
ngOnInit(): void { ngOnInit(): void {
this.postId = this.activatedRoute.snapshot.paramMap.get('id');
console.log(this.postId);
} }
} }
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router'; import { Routes, RouterModule } from '@angular/router';
import { PostDetailsComponent } from './components/post-details/post-details.component';
import { PostListComponent } from './components/post-list/post-list.component';
import { PostComponent } from './post.component'; import { PostComponent } from './post.component';
const routes: Routes = [{ path: '', component: PostComponent }]; const routes: Routes = [
{
path: '',
component: PostComponent,
children: [
{
path: '',
component: PostListComponent,
},
{
path: 'details/:id',
component: PostDetailsComponent,
},
],
},
];
@NgModule({ @NgModule({
imports: [RouterModule.forChild(routes)], imports: [RouterModule.forChild(routes)],
......
<app-post-header></app-post-header> <app-post-header></app-post-header>
<app-post-list></app-post-list> <router-outlet></router-outlet>
...@@ -7,7 +7,7 @@ $grey-1: #333333; ...@@ -7,7 +7,7 @@ $grey-1: #333333;
$grey-2: #4f4f4f; $grey-2: #4f4f4f;
$grey-3: #828282; $grey-3: #828282;
$grey-4: #bdbdbd; $grey-4: #bdbdbd;
$grey-6: #f2f2f2; $grey-6: #f8f8f8;
/* form colors */ /* form colors */
$green-1: #47c562; $green-1: #47c562;
/* Status colors */ /* Status colors */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment