当前位置: 首页 > 知识库问答 >
问题:

带Firebase和Cloud Firestore的角9后端

夏晋
2023-03-14
 items: Array<any>;

  constructor(private aboutUsService: AboutUsService) { }

  ngOnInit() {
    this.getData();
  }

  getData() {
    this.aboutUsService.getContent()
    .subscribe(data => {
      this.items = data;
      console.log('items: ',  this.items);
    }, // Bind to view
    err => {
      console.log(err);
    });
  }
  getContent() {
    return this.db.collection('aboutus').snapshotChanges();
  }

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if true;
    }
  }
}

服务响应并返回以下数组,其中包含一个元素(这是this.Items的内容):

[{…}]
0:
payload: {type: "added", doc: n, oldIndex: -1, newIndex: 0}
type: "added"

以下是Chrome network选项卡中的标题:

Request URL: http://localhost:4200/aboutus
Request Method: GET
Status Code: 304 Not Modified
Remote Address: 127.0.0.1:4200

但是我无法找到集合的数据来在前端显示它(变量this.items)。

共有1个答案

经伟
2023-03-14
getContent() {
  return this.db.collection('aboutus').valueChanges();
}
 类似资料:
  • 我已经创建了一个spring boot后端和一个angular前端,现在我想使用sprint boot在8080上运行,其主页显示索引。html(来自angular)。 我已经使用ng build--prod命令在angular中创建了dist文件夹,并将其复制到(src/main/resources/static)文件夹中。在此处输入图像描述 除此之外,我读了很多关于这个的stackoverfl

  • null 他们的东西更简单?在解析中,我使用了云代码,我希望逻辑不在客户端,而是在服务器端。

  • 我正在尝试使用Spring Security(4.1.3)和Angular 2.0.1实现CSRF保护 相关话题的来源很多,但我找不到明确的说明。有些说法甚至相互矛盾。 我读过关于springs的操作方法(尽管指南中描述了Angular 1 way)Spring Security guide,其中包含Angular,即

  • 我试图从一个应用程序(spring-boot应用程序)调用另一个应用程序(angularjs)上的RESTendpoint。应用程序正在下列主机和端口上运行。 REST应用程序,使用Spring Boot, HTML应用程序,使用angularjs, 处理程序所做的只是根据用户是否登录、身份验证失败或注销,写出类似的JSON响应。如下所示。 对我错过了什么或者做错了什么有什么想法吗?