在 angular fire文档中,这是我试图理解的两行:
// To make the data available in the DOM, assign it to $scope
$scope.data = obj;
// For three-way data bindings, bind it to the scope instead
obj.$bindTo($scope, "data");
Run Code Online (Sandbox Code Playgroud)
他们在做同样的事情吗?两者都绑定到 3 路数据绑定的范围吗?
snapshot如此CodePen所示,我能够获取我感兴趣的对象
以下是代码片段:
$scope.post = {};
var postsRef = new Firebase('https://docs-examples.firebaseio.com/web/saving-data/fireblog/posts');
$scope.searchPost = function () {
console.log('searched for author : ' + $scope.post.authorName);
postsRef.orderByChild('author')
.equalTo($scope.post.authorName)
.once('value', function (snapshot) {
var val = snapshot.val();
console.log("Searched Post is : ");
console.log(val);
console.log("(From Val) Title is : " + val.title);
var exportVal = snapshot.exportVal();
console.log("Export Value is : ");
console.log(exportVal);
console.log("(From Export Val) Title is : " + exportVal.title);
});
}
Run Code Online (Sandbox Code Playgroud)
这是我使用的Firebase 数据集。
当我搜索 author: 时gracehop,我得到了正确的快照,但是,我无法访问title …
我最近开始将我的 iOS 应用程序也转变为网络应用程序。我不知道这个实现是否正确。它有效,但如果有人可以请告诉我它是否正确。
这是我的 LicenseService 中的函数:
get retriveLicences():Licence[] {
const licences: Licence[] = [];
this.afDatabase.list(this.basePath).valueChanges().subscribe((snapshot) => {
snapshot.forEach(element => {
const licenceObject = <any>element
licences.push(
new Licence(
licenceObject.name,
licenceObject.logoUrl,
licenceObject.maxUsers,
licenceObject.currentUserCount,
licenceObject.startDate,
licenceObject.endDate
)
);
});
});
return licences
}
Run Code Online (Sandbox Code Playgroud) typescript angularfire firebase-realtime-database angularfire2 angular
我正在处理一个 android 应用程序的管理模块。管理模块是一个基于 Angular 的网络应用程序。Firebase auth(Email/password) 用于以管理员身份登录。我已经向 firebase 添加了一个手动凭据条目,管理员正在使用这些凭据登录(因为管理员没有注册功能)
另一方面,Android 开发人员也使用相同的 Auth 方法来登录用户。因此,android 应用程序的用户可以使用他们的凭据登录到 Admin 模块。
如何防止 android 用户登录到 web 应用程序。是否有任何方法或规则可用于过滤传入的登录请求并仅当电子邮件属于 Admin 时才允许登录?
firebase firebase-security angularfire firebase-authentication
Angular - v13.1 Firebase - ^9.6.2
在旧版本的 firebase 中,可以将 firebase 导入到 Angular 组件中以利用该serverTimestamp属性:
import firebase from 'firebase/app';
import 'firebase/firestore';
---
this.afs.doc(`${db_path}`).set({
dateCreated: firebase.firestore.FieldValue.serverTimestamp(),
)};
Run Code Online (Sandbox Code Playgroud)
然而,自从新版本出现后,这种方法似乎不再起作用了。查看文档,我(...尚未)发现任何建议将 firebase 导入组件以使用此值的替代方法。
是否有更好的方法来利用时间戳类型设置为值?
我需要以相反的顺序向Firebase添加对象.或者在进行数据绑定时反转数据.或者按创建时间对对象进行排序.
var ref = new Firebase("https://[url].firebaseio.com/");
$scope.messages = $firebase(ref);
$scope.addMessage = function(e) {
$scope.messages.$add({title: $scope.title, body: $scope.msg, time: $scope.getDate() });
}
<div class="well span3 pull-left note" ng-repeat="(key, msg) in messages">
<button type='button' class='close' ng-click="messages.$remove(key)">×</button>
<b>{{msg.time| date: 'medium'}}</b>
<span>{{msg.title}}</span>
<span>{{msg.body}}</span>
<button ng-click="changeMessage(key)" class="btn btn-mini pull-right"><i class="icon-pencil"></i></button>
</div>
Run Code Online (Sandbox Code Playgroud)
我尝试使用OrderBy属性进行ng-repeat,但这并不容易,因为在消息中存储了对象.
这是我为Firebase为应用程序构建的一项简单服务.我不得不对一些元素进行评审,我已经确定我使用的是最新版本的firebase和angular fire,因为它看起来变化很快.前几行很简单,
app.factory('Ship', function ($routeParams, $firebase, FIREBASE_URL) {
var ref = new Firebase(FIREBASE_URL + 'ships');
Run Code Online (Sandbox Code Playgroud)
问题从这里开始.根据我打算对firebase对象做什么,有时它需要是$ asObject,有时则不是.这取决于教程,最近的教程似乎表明了这一点
var shipsObj = $firebase(ref).$asObject(); // Is this necessary
var ships = $firebase(ref); // in the most modern version?
var Ship = {
all: shipsObj, // This works fine
create: function (ship) {
return shipsObj.$add(ship); // This also works fine
},
find: function (shipId) {
console.log($routeParams.shipId); // <--this ID appears as the correct numerical ID
Run Code Online (Sandbox Code Playgroud)
然后,接下来有六行,其中没有一行有效.它们都会产生错误,表明它们未定义.
console.log(shipsObj.$child(shipId));
console.log(ships.$child(shipId));
console.log(shipsObj.$getRecord(shipId));
console.log(ships.$getRecord(shipId));
console.log(ships.$keyAt(shipId));
console.log(shipsObj.$keyAt(shipId)); …Run Code Online (Sandbox Code Playgroud) 我正在使用angularFire并尝试使用$ add将数据从表单保存到firebase.任何帮助将不胜感激.控制台记录所有工作,我能够在控制台中检索数据.对不起所有的代码...我想确保我提供了所需的所有材料.
app.js:
var creativeBillingApp = angular.module('creativeBillingApp', ['ngRoute', 'firebase']);
creativeBillingApp.constant('FIREBASE_URI', "https://XXXX.firebaseIO.com/");
creativeBillingApp.controller('MainCtrl', ['$scope', 'groupsService', function( $scope, groupsService, $firebase ) {
console.log('Works')
$scope.newGroup = {
name: '',
status: ''
};
$scope.addGroup = function(newGroup){
console.log(newGroup);
groupsService.addGroup();
$scope.newGroup = {
name: '',
status: ''
};
};
$scope.updateGroup = function (id) {
groupsService.updateGroup(id);
};
$scope.removeGroup = function(id) {
groupsService.removeGroup(id);
};
}]);
creativeBillingApp.factory('groupsService', ['$firebase', 'FIREBASE_URI',
function ($firebase, FIREBASE_URI) {
'use strict';
var ref = new Firebase(FIREBASE_URI);
return $firebase(ref).$asArray();
var groups = $firebase(ref).$asArray();
var getGroups = …Run Code Online (Sandbox Code Playgroud) 我试图通过电子邮件/密码功能获得AngularFire用户身份验证,但我收到错误.
从$ authWithPassword调用发回的错误是:
错误:此自定义Firebase服务器('firebaseapp.com')不支持委派登录.
您可以在下面的plunker的控制台日志中查看此消息.我找不到任何有关需要任何其他设置以支持委派登录的文档,或者我将如何操作.
plunker的控制台日志还会显示对firebase应用程序URL的定期Web请求,这些请求会产生404.这些请求在$ firebaseAuth(ref)调用完成后立即开始.这些回复的内容是一个HTML页面,标题为:找不到网站.
我有一个演示用户'demo@zerrtech.com',密码'demo'和一个样本plunker设置在这里.这是代码:
angular.module('authdemo', ['firebase'])
.controller('authCtrl', function($scope, $log, $firebaseAuth) {
var ref = new Firebase('https://zerrtech-sandbox.firebaseapp.com');
var auth = $firebaseAuth(ref);
auth.$authWithPassword({
email: 'demo@zerrtech.com',
password: 'demo'
}).then(function(authData) {
$log.info("Login Successful:");
$log.info(authData);
}).catch(function(error) {
$log.info("Login Failed:");
$log.info(error);
});
});
Run Code Online (Sandbox Code Playgroud)
这是一个非常基本的用例,代码就是示例,所以我错过了什么?
我们如何从angularfire查询firebase以匹配两个条件.我想在以下两个条件下搜索AND匹配
或者什么是firebase中的验证,如.indexOn或.validate
json就像
{
"color" : {
"-UqPNlZ8ddgdGMFSsD" : {
"color" : "red",
"categories" : {
"hex" : {
"subcategory" : [ "#111", "#333" ]
}
},
"status" : "ok"
},
"-U9P4pBpYiId3ID64K" : {
"color" : "blue",
"categories" : {
"hex" : {
"subcategory" : [ "#ddd", "#eee" ]
}
},
"status" : "ok"
},
"-U9UgOdffZdfdbSydF" : {
"color" : "green",
"categories" : {
"hex" : {
"subcategory" : [ "#333", "#555" ]
} … angularfire ×10
firebase ×8
angularjs ×4
javascript ×3
angular ×2
angularfire2 ×1
typescript ×1