简体   繁体   English

Angular 5-如何正确设置网站帖子

[英]Angular 5 - How to properly set up posts for website

I'm learning angular and trying to build a personal website with it as well as firebase. 我正在学习有角度的东西,并试图用它以及firebase建立一个个人网站。 I'm trying to figure out the best approach for making posts on the webpage. 我正在尝试找出在网页上发布帖子的最佳方法。 Should I make each post a component? 我应该使每个帖子都成为组件吗? I want to be able to keep the posts unique, but similar formatting style. 我希望能够使帖子保持唯一性,但格式样式相似。

Another idea is to put the posts in the firebase backend: have a posts collection, and a document for each post that has similar fields. 另一个想法是将帖子放置在firebase后端中:有一个帖子集合,以及每个具有相似字段的文档。

I would like to be able to modify the javascript of each post individually in case I want to get creative. 我希望能够单独修改每个帖子的javascript,以防我想变得有创意。 Have been doing some research on my own but thought I'd ask those who have more experience with Angular. 我一直在自己做一些研究,但以为我会问那些对Angular有更多经验的人。

I would do create the following for showing the posts: 我会创建以下内容来显示帖子:

  • post-list-component 后列表的组件
  • post-component 后组件
  • service post 服务站
  • post 岗位

post : class representing the post you want to store in firebase post :表示要存储在firebase中的帖子的类

post-service : service handling the communication with backend/firebase 后期服务 :处理与后端/ firebase通信的服务

post-list-component :view component that asks the post-service for all post and then iterate over the response populating a list of post-components post-list-component :view组件,它向后服务询问所有帖子,然后遍历响应,以填充后组件列表

post-component : View component styled for the post you fetched from firebase and iterate over in post-list-component. post-component :查看您从firebase提取并在post-list-component中进行迭代的帖子的样式的查看组件。

And if you want different handling of different posts you can implement dynamic component loader. 而且,如果您希望对不同的帖子进行不同的处理,则可以实现动态组件加载器。 Here is a good example: https://angular.io/guide/dynamic-component-loader 这是一个很好的例子: https : //angular.io/guide/dynamic-component-loader

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM