angularFire $ bind方法可以在这里找到:http://angularfire.com/flatdoc.html 和最新的ng-grid可以在这里找到:http://angular-ui.github.io/ng-grid/
我尝试了最简单的解决方案,但它没有用:
$scope.myData = [{name: "Moroni", age: 50},
{name: "Tiancum", age: 43},
{name: "Jacob", age: 27},
{name: "Nephi", age: 29},
{name: "Enos", age: 34}];
$scope.gridOptions = {
data: 'myData',
rowTemplate:'<div ng-style="{\'cursor\': row.cursor, \'z-index\': col.zIndex(), \'color\': \'rgb(248, 248, 248)\',\'background\': \'none repeat scroll 0% 0% rgba(51, 51, 51, 0.7)\' }" ng-repeat="col in renderedColumns" ng-class="col.colIndex()" class="ngCell {{col.cellClass}}" ng-cell></div>',
headerRowTemplate: '<div ng-style="{ height: col.headerRowHeight,\'color\': \'rgb(248, 248, 248)\',\'background\': \'none repeat scroll 0% 0% rgba(51, 51, 51, 0.7)\' …Run Code Online (Sandbox Code Playgroud) 假设我有一些文章:
https://example.firebaseio.com/articles/$key
Run Code Online (Sandbox Code Playgroud)
我想添加一个viewCounter和currentUsersCounter孩子们articles.
https://example.firebaseio.com/articles/$key/viewCounter
https://example.firebaseio.com/articles/$key/currentUsersCounter
Run Code Online (Sandbox Code Playgroud)
我在用户滚动到下一篇文章时随时执行一个函数:
var currentArticle = function(key){
//key == index of the article
//This is where I want to increment the `viewCounter` and `currentUsersCounter`
}
Run Code Online (Sandbox Code Playgroud)
显然,我不希望任何人写这两个孩子的东西.
如何将当前(黑名单所有写入)的安全规则扩展为仅针对这些特定集合的白名单写入?
如何在这些列入白名单的集合的安全规则中限制对唯一IP地址的写入?(如果可能的话)
目前黑名单所有写入:
{
"rules": {
".read": true,
".write": "auth.email == 'example@gmail.com'"
}
}
Run Code Online (Sandbox Code Playgroud) 我想将数据保存到firebase多子节点:
--Events
----Races
-------Participants
Run Code Online (Sandbox Code Playgroud)
这是一个虚拟数据,这是我想要保存到firebase的一种数据
var dummyData = [
{
event_id: 1,
event_venue: "Churchill Ground Venue",
event_name: "Victoria Cup",
event_type: "Holiday Special",
event_datetime: now,
event_url: 'www',
races: {
1: {
race_id: 1,
race_type: "Horse Race",
race_url: "www",
race_name: "Super Hourse 8",
race_venue: "Ground No 7",
race_datetime: now,
races_participants: {
1: {
participants_id: 1211,
participants_name: "Doll Fire",
participants_place_odds: 10,
participants_win_odds: 5,
participants_result: 0,
}
}
},
2: {
race_id: 2,
race_type: "Horse Race 2",
race_url: "www",
race_name: "Super Hourse 9",
race_venue: …Run Code Online (Sandbox Code Playgroud) 我是AngularJS的新手,并试图将它与AngularFire/Firebase结合使用来存储一些项目数据.我建立了一个工厂,应该处理通知,以便在中心位置显示它们.工厂看起来像这样:
myApp.factory("AlertService", function($timeout){
var alerts = new Array();
var addAlert = function(type, message){
alerts.push({
type: type,
msg: message
});
$timeout(function(){
removeAlert(alerts.length - 1);
}, 3000);
}
var removeAlert = function(index){
alerts.splice(index, 1);
}
return{
alerts : alerts,
addSuccessAlert : function(message){
addAlert("success", message);
},
addDangerAlert : function(message){
addAlert("danger", message);
},
deleteAlert : function(index){
removeAlert(index);
}
};
});
Run Code Online (Sandbox Code Playgroud)
绑定控制器中的数据我用$ watch
$scope.$watch( function () { return AlertService.alerts; }, function ( alerts ) {
$scope.alerts = AlertService.alerts;
});
Run Code Online (Sandbox Code Playgroud)
并在index.html中放置了一个div:
<div id="alert">
<alert ng-repeat="alert in …Run Code Online (Sandbox Code Playgroud) 我正在使用AngularFire和Firebase,我想获得我刚刚通过该$add()方法添加的元素的键.有一种记录的方法可以使用"vanilla"Firebase执行此操作,请参阅此处的 "获取由push()生成的唯一ID" .但是,它似乎与AngularFire不相同$id.
var ref = $firebase(firebaseData.ref()).$asArray();
var newItem = ref.$add({fruit: "apple", color: "red"});
var itemId = newItem.$id;
// Do stuff with itemID...
Run Code Online (Sandbox Code Playgroud)
newItem已使用新密钥(例如-Jf-06c0QX_vMMNL3Aek)成功添加到Firebase ,但itemId返回undefined.
有没有办法做到这一点?
我在Firebase中有不同的部分和规范化数据,我有例程来获取信息,但我不能遍历返回的记录来获取数据.我想使用$ firebaseArray()中的键从其他$ firebaseObject()中获取数据.
GetOneTeam() .... {
var DataRef = GetFireBaseObject.DataURL(Node + '/'); // xxx.firebaseio.com/Schedules/
var OneRecordRef = DataRef.child(Key); // Schedule Key - 1
return $firebaseObject(OneRecordRef);
}
...
var Sched = GetOneSchedule('Schedules', 1);
... // For Loop getting data - Put in HomeId
var TeamRec = GetOneTeam('Teams', HomeId);
var Name = TeamRec.TeamName; // Does not TeamName value from Schedule/1
Run Code Online (Sandbox Code Playgroud)
如果上面的代码段不够清楚,以下是更多的实际代码.获取数据的常用例程示例:
angular.module('MyApp')
.constant('FIREBASE_URL', 'https://xxxxxxxx.firebaseio.com/');
angular.module('MyApp')
.factory('GetFireBaseObject', function(FIREBASE_URL) {
return {
BaseURL: function() {
return new Firebase(FIREBASE_URL);
},
DataURL: function(Node) {
return new …Run Code Online (Sandbox Code Playgroud) 我正在尝试搜索带有id的项目,但是我收到了此消息.所有功能都正常工作.执行时我收到此错误:
使用Firebase中的数组索引存储数据可能会导致意外行为.有关 详细信息,请参阅 https://www.firebase.com/docs/web/guide/understanding-data.html#section-arrays-in-firebase.
我的工厂
.factory('TEST', function ($firebaseArray) {
var ref = new Firebase('https://shark-firebase.firebaseio.com');
return {
all: function(section) {
var data = $firebaseArray(ref.child(section));
return data;
},
get: function(section, id) {
var data = $firebaseArray(ref.child(section).child(id));
return data;
}
};
});
Run Code Online (Sandbox Code Playgroud)
我一起试试:
get: function(section, id) {
var data = $firebaseArray(ref.child(section));
return data.$getRecord(id);
}
Run Code Online (Sandbox Code Playgroud)
和我的控制器:
如果是,$ stateParams.section ='posts'和$ stateParams.id ='0'.
$scope.loadItem = function(){
$scope.item = TEST.get($stateParams.section, $stateParams.id);
};
Run Code Online (Sandbox Code Playgroud) 我有一个情况,我必须把嵌套ng-repeat,当我试图得到的$id第一个ng-repeat我没有任何问题,但当我试图获得$id第二个ng-repeat(下图中标记为红色)我got undefined.
我的Firebase结构如下
HTML代码和控制器在这里
angular
.module('starter')
.controller('feedController', function($scope, $firebaseRef, $firebaseArray) {
$scope.allRequests = $firebaseArray($firebaseRef.requests);
$scope.allRequests.$loaded(function() {
console.log(arguments);
})
})Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<span ng-repeat="items in allRequests">
<!-- this works fine -->
{{items.$id}}
<div ng-repeat="item in items">
<!-- getting undefined here... -->
{{item.$id}}
</div>
</span>Run Code Online (Sandbox Code Playgroud)
我需要$id第二ng-repeat,任何帮助将不胜感激.
我想在AngularJS和FireBase(管理员,用户)中进行基于角色的简单授权.我做了基本授权和路由(看下面的3个文件).
我在github和文章中找到了一个存储库,但代码对我来说太难了.有没有更简单的方法?如何更改代码以添加此功能?我将非常感谢能够帮助我的文章和存储库的链接.
app.js
var app = angular.module( 'journalApp', [ 'firebase', 'ngRoute' ] );
app.constant( 'FIREBASE', '<FIREBASE URL>' );
app.config( [ '$routeProvider', '$locationProvider', function( $routeProvider, $locationProvider ) {
$routeProvider.when( '/login', {
templateUrl: 'views/login.html',
controller: 'loginCtrl',
controllerAs: 'loginCtl'
} );
$routeProvider.when( '/logout', {
templateUrl: 'views/login.html',
controller: 'loginCtrl',
controllerAs: 'loginCtl',
resolve: {
"logout": [ "authService", function( authService ) {
authService.signOut();
}]
}
} );
$routeProvider.when( '/', {
templateUrl: 'views/dashboard.html',
resolve: {
"currentAuth": [ "authService", function( authService ) {
var …Run Code Online (Sandbox Code Playgroud) 我有一个Object Observable
private Room = AngularFire.database.object(`/Rooms/`);
Run Code Online (Sandbox Code Playgroud)
这个可观察的内部有许多价值,但我有一个孩子叫Empty.这是设置为true空时和false不时.
我只想查询并从observable中获取一个房间.我该怎么做呢?这是我第一次尝试没有查询使用forEach哪个不是我想要使用的东西.
this.Room.subscribe(list => {
list.forEach(snapshot =>{
if(snapshot.Empty == "true")
console.log(snapshot);
})
Run Code Online (Sandbox Code Playgroud)