added create page and updated auth
This commit is contained in:
@ -0,0 +1,36 @@
|
||||
import { Component, effect, inject, signal } from '@angular/core';
|
||||
import { PostEditorComponent } from '../../../components/post-editor/post-editor.component';
|
||||
import { Post } from '../../../shared/interfaces/post';
|
||||
import { PostsService } from '../../../shared/services/posts.service';
|
||||
import { Location } from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-create-post',
|
||||
imports: [PostEditorComponent],
|
||||
templateUrl: './create-post.component.html',
|
||||
})
|
||||
export class CreatePostComponent {
|
||||
private postsService = inject(PostsService);
|
||||
private location = inject(Location);
|
||||
post = signal<Post>({
|
||||
id: 0,
|
||||
title: '',
|
||||
tldr: '',
|
||||
content: '',
|
||||
});
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
console.log('create', this.post());
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
this.post.set({ ...this.post(), title: 'adf' });
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
publish() {
|
||||
this.postsService.createPost(this.post());
|
||||
this.location.back();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user