我想将来自customers表的init数据加入到项目列表中.
模型是这样的:
项目
顾客
你有一个例子,我如何使用angularfire2从angular2组件做到这一点?
我的控制器看起来像这样:
import { Component, OnInit } from '@angular/core';
import { Project } from '../project';
import { Router } from '@angular/router';
import { FirebaseAuth } from 'angularfire2';
import { AngularFire, FirebaseListObservable, FirebaseObjectObservable } from 'angularfire2';
import { Observable } from 'rxjs';
@Component({
moduleId: module.id,
selector: 'app-projects',
templateUrl: 'projects.component.html',
styleUrls: ['projects.component.css']
})
export class ProjectsComponent implements OnInit {
projects: FirebaseListObservable<any[]>;
customers: FirebaseListObservable<any[]>;
projectName: string;
constructor(
private router: Router,
private af: AngularFire
) …Run Code Online (Sandbox Code Playgroud) 我将非常感谢有关如何在Firebase中重新验证用户的帮助.如果文档没有解释如何使用它,我想知道添加所有这些强大的功能是否有任何意义:
目前,这正是我正在尝试的,而且它无法正常工作.错误如cannot read property 'credential' of undefined
在构造函数中:
constructor(@Inject(FirebaseApp) firebaseApp: any) {
this.auth = firebaseApp.auth();
console.log(this.auth);
}
Run Code Online (Sandbox Code Playgroud)
那么功能
changePassword(passwordData) {
if(passwordData.valid) {
console.log(passwordData.value);
// let us reauthenticate first irrespective of how long
// user's been logged in!
const user = this.auth.currentUser;
const credential = this.auth.EmailAuthProvider.credential(user.email, passwordData.value.oldpassword);
console.log(credential);
this.auth.reauthenticate(credential)
.then((_) => {
console.log('User reauthenticated');
this.auth.updatePassword(passwordData.value.newpassword)
.then((_) => {
console.log('Password changed');
})
.catch((error) => {
console.log(error);
})
})
.catch((error) => {
console.log(error);
})
}
}
Run Code Online (Sandbox Code Playgroud) 最近AngularFire如何处理对象/列表以及引用整个应用程序中的对象,我们遇到了一些严重的问题.
主要的是旧的AngularFireObject & AngularFireList工作与新的相比.我们的应用程序高度依赖于$key价值,因为我们非常规范化(如推荐).
现在,文档使用一个map示例来获取$key值,但是它的工作方式不一样,甚至valueChanges()看起来效果也不一样.
我不完全确定我们现在应该做些什么改变.
/* /items/
a/{name: 'Dennis', city: 'Dallas'}
b/{name: 'Katie', city: 'Austin'}
c/{name: 'Will', city: 'Chicago'}
*/
let myAfList = this.af.list('path/to/items');
let itemsFirst, itemsSecond, itemsThird;
myAfList.subscribe(items => itemsFirst = items);
setTimeout(_ => myAfList.subscribe(items => itemsSecond = items), 1000);
setTimeout(_ => myAfList.subscribe(items => itemsThird = items), 2000);
/* Results for all three item arrays
itemsFirst: [
{name: 'Dennis', city: 'Dallas', $key: 'a'},
{name: 'Katie', city: 'Austin', $key: …Run Code Online (Sandbox Code Playgroud) 在视图中显示Firebase错误消息(error.message)会导致英语错误说明(例如,对于身份验证错误,如果用户凭据包含错误).
您将如何以不同语言显示消息(最佳情况:使用手机语言)?
error-handling firebase firebase-authentication angularfire2 angular
我使用Firebase作为我的Angular 5应用程序的数据库.我能够使用ng build构建,运行和部署项目.但是,当我使用--prod标志构建时,我收到以下错误.
使用:
ng build --prod
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
在"FirebaseModule"的模板编译期间出现错误错误在装饰器中不支持函数调用,但调用了"AngularFireModule".
我不明白如何配置AngularFire模块以使其工作.
Firebase.Module.ts:
import { NgModule } from "@angular/core";
import { CommonModule } from "@angular/common";
import { environment } from "../environments/environment"; // Firebase config stored in environment file
import { AngularFireAuthModule } from "angularfire2/auth";
import { AngularFireModule } from "angularfire2/angularfire2";
import { AngularFirestoreModule } from "angularfire2/firestore";
@NgModule({
imports: [
AngularFireModule.initializeApp(environment.firebase), // Error is here
AngularFireAuthModule,
AngularFirestoreModule
],
exports: [AngularFireModule, AngularFireAuthModule, AngularFirestoreModule],
providers: [],
declarations: []
})
export class FirebaseModule {}
Run Code Online (Sandbox Code Playgroud)
environment.ts(和environment.prod.ts)
export …Run Code Online (Sandbox Code Playgroud) 从今天早上开始,我们的Firebase应用程序在将数据写入 Realtime Database实例时出现问题.即使是最简单的任务,例如向对象添加一个键值对也会触发
Error: TRIGGER_PAYLOAD_TOO_LARGE: This request would cause a function payload exceeding the maximum size allowed.
特别奇怪,因为我们的代码或数据库中的任何内容都没有变化超过24小时.
即使是简单的事情
Database.ref('environments/' + envkey).child('orders/' + orderkey).ref.set({a:1})
Run Code Online (Sandbox Code Playgroud)
触发错误.
显然,有效载荷的大小不是问题,但是可能导致这种情况的原因是什么?
数据库结构,按要求
environments
+-env1
+-env2
--+orders
---+223344
-----customer: "Peters"
-----country: "NL"
-----+items
------item1
-------code: "a"
-------value: "b"
------item2
-------code: "x"
-------value: "2"
我正在尝试在 iOS 模拟器上测试一些 Ionic/Angular 示例应用程序。
在网络上,所有使用 AngularFire 进行 Firestore 的请求都工作得很好。
不知何故,如果我尝试在模拟器上执行相同的应用程序,它会不断加载请求的响应(如果它是空响应,则会说无法检索到任何结果)。
到底是怎么回事?我是否需要专门设置一些内容以使模拟器能够工作并执行对 Firestore 的请求?
ios ionic-framework angularfire2 angular google-cloud-firestore
我将 AngularFire 升级到 7,并且在使用 .where 和 collectionReference 时遇到问题。那么简单..如何正确使用它?
我尝试使用“@angular/fire/firestore”中的“集合”,例如:
const ref = collection(this.firestore, 'collectionName');
Run Code Online (Sandbox Code Playgroud)
但裁判没有说“哪里”之类的。
我知道“@angular/fire/firestore”也有“query”和“where”,但我不知道如何使用它。
如何使用新 API 的“where”在集合中查找文档?
javascript firebase google-cloud-platform angularfire2 google-cloud-firestore
我正在浏览Firestore文档和指南.我下面的代码示例使用AngularFire2.
让我们考虑类似于此处提供的示例的"聊天"集合:https://firebase.google.com/docs/firestore/manage-data/structure-data
他们推荐这种结构,但我不知道他们在哪里讨论有效地获取所有数据.
每个聊天文档都有属性,成员集合和消息集合:
Firestore查询很浅,有时可能很棒.我的理解是,没有编入方式来深入查询并获取嵌套集合.那么,最好的做法和最无忧无虑的方法是什么?
目前我正在检索快照并将快照映射到具有ID的对象,并将嵌套的集合数据添加到父文档数据中,并附加查询和映射,我对我的方法感到不满意,即使使用非规范化的Firebase也可以更快地完成结构.
这个代码示例只是在成员上映射,在消息中添加回来是另一个故事......
getChatsFromFirestore() {
this.chats = this.dataSvc.getChatsFromFirestore().snapshotChanges()
.map(chatSnaps => {
return chatSnaps.map(chat => {
const chatData = chat.payload.doc.data();
const chatId = chat.payload.doc.id;
return this.dataSvc.getMembersForChat(chatId)
.snapshotChanges()
.map(memberSnaps => {
return memberSnaps.map(member => {
const data = member.payload.doc.data();
const id = member.payload.doc.id;
return { id, ...data }
});
})
.map(members => {
return { chatId, ...chatData, members: members };
});
})
})
.flatMap(chats => Observable.combineLatest(chats)); …Run Code Online (Sandbox Code Playgroud) firebase typescript angularfire2 angular google-cloud-firestore
我正在尝试为我的Angular 6应用添加firebase支持但是在添加angularfire2时
npm install angularfire2 firebase
Run Code Online (Sandbox Code Playgroud)
我得到很多警告说我必须使用Angular 5.例如
npm WARN angularfire2@5.0.0-rc.6.0 requires a peer of @angular/core@^5.0.0 but none is installed. You must install peer dependencies yourself.
Run Code Online (Sandbox Code Playgroud)
今天可以使用angularfire2和Angular 6吗?
编译时出现此错误:
ERROR in node_modules/angularfire2/angularfire2.d.ts(3,10): error TS2305: Module '"/home/rrr/Projects/ng6test/node_modules/rxjs/Subscription"' has no exported member 'Subscription'.
node_modules/angularfire2/firebase.app.module.d.ts(10,22): error TS2720: Class 'FirebaseApp' incorrectly implements class 'FirebaseApp'. Did you mean to extend 'FirebaseApp' and inherit its members as a subclass?
Property 'automaticDataCollectionEnabled' is missing in type 'FirebaseApp'.
node_modules/rxjs/Subscription.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Subscription'.
Run Code Online (Sandbox Code Playgroud)
我试图安装rxjs-compat,但之后又收到了警告
ERROR in …Run Code Online (Sandbox Code Playgroud) angularfire2 ×10
firebase ×8
angular ×5
javascript ×3
typescript ×2
angular5 ×1
angular6 ×1
angularjs ×1
ios ×1
rxjs ×1