angularfire

How to mock out Firebase in Karma tests for Angular app

心已入冬 提交于 2019-12-06 05:11:32
问题 By following the AngularFire guide, I have synchronized a scope variable with a Firebase array. My code is basically the same as the tutorial (Step 5): https://www.firebase.com/docs/web/libraries/angular/quickstart.html Everything in my app is working, but I am really confused about how to properly mock the Firebase call in my Karma unit tests. I guess something along the lines of using $provide to mock the data? But then $add wouldn't work in my controller methods. Help? 回答1: Copied from

How to extend returned objects in the list returned by $asArray?

跟風遠走 提交于 2019-12-06 04:21:25
I'm having trouble decorate the objects in my list returned by $asArray in angularfire with a new method (not decorating the array itself). The angularfire documentation seems to suggest that the right way to do this is to override the $$added method in the factory for $FirebaseArray, returning a new object that either encapsulates or extends the snapshot that gets passed in to that method. From the documentation : // an object to return in our JokeFactory app.factory("Joke", function($firebaseUtils) { function Joke(snapshot) { this.$id = snapshot.name(); this.update(snapshot); } Joke

Filter Firebase data using AngularJS

那年仲夏 提交于 2019-12-06 02:09:17
问题 i have a data in firebase like this: firebase_data { -JGc5X37NDuvmJylmx0s: Object { name: 'John Doe', age: 21 } -JGnGJlTjyAxFT-Vn48Y: Object { name: 'Jane Doe', age: 22 } } in my controller: $scope.firebase = $firebase(new Firebase("https://firebase_data.firebaseio.com")); my view: <input type="text" ng-model="search" /> <ul ng-repeat="(key, value) in firebase | filter:search"> <li><a href="{{ key }}">{{ value.name }}</a></li> </ul> the filter is not working. how can i make the filter work?

Using Limits with AngularFire

不想你离开。 提交于 2019-12-06 01:01:21
This is the code I have right now: var url = 'https://*****.firebaseio.com/photos'; var promise = angularFire(url, $scope, 'photos', {}); promise.then(function() { //limit here. }); What code can I insert to limit what is returned from the firebase to only those have a specified priority (let's say the priority is "new)? Thanks for the help. Just pass in an already limited query to angularFire, like so: var ref = new Firebase("https://*****.firebaseio.com/photos"); var promise = angularFire(ref.startAt("new"), $scope, "photos", {}); 来源: https://stackoverflow.com/questions/17179532/using-limits

How to enable route security when using AngularFire with Angular ui-router?

不打扰是莪最后的温柔 提交于 2019-12-05 23:30:12
问题 Is it possible to use theAngularFire routeSecurity module with angular UI-ROUTER instead of the standard ng-route provider? Is there a version of routeSecurity that would work with ui-router? 回答1: @mattvv Gave me this gist while I was talking on him in the angular irc channel. So essentially you would just need to replace the routesecurity.js file in angularfire directory assuming that you used yeoman to scaffold your application. A neat thing to do is just to create another file named

angularfire 2: Error “Unhandled Promise rejection: TypeError: Cannot read property”

吃可爱长大的小学妹 提交于 2019-12-05 21:25:54
I tried an example app to connect to Firebase In my Main.ts I wrote this: import { bootstrap } from '@angular/platform-browser-dynamic'; import { enableProdMode } from '@angular/core'; import { AppComponent, environment } from './app/'; import { FIREBASE_PROVIDERS, defaultFirebase, firebaseAuthConfig, AuthProviders, AuthMethods } from 'angularfire2'; if (environment.production) { enableProdMode(); } bootstrap(AppComponent,[ FIREBASE_PROVIDERS, defaultFirebase({ apiKey: "MYKEY", authDomain: "MYDOMAIN.firebaseapp.com", databaseURL: "https://MYDOMAN.firebaseio.com", storageBucket: "MYDOMAIN

Fetching item by unique firebase id in angularfire 1.0.0

你。 提交于 2019-12-05 20:41:50
I have trouble fetching one unique item from my firebase using angularfire 1.0.0. To clarify, I want my app to fetch a post given a unique firebase id e.g. "-JkZwz-tyYoRLoRqlI_I". It works when navigating in the app e.g. clicking on a link to a specific post, but not on a refresh. My guess is that it has something to do with synchronization. Right now it works when fetching all posts and use it in a ng-repeat. This is a clue to why it works for one item when navigating to the page. This should probably not be hard since this should be a pretty standard operation, but i can't get it to work. I

Angularfire2: logout exception & best practices

冷暖自知 提交于 2019-12-05 20:26:38
问题 After logging in, I subscribe to some firebase refs, and then subsequently logout (FirebaseAuth.logout). Once I logout, I get a Firebase warning in the console: "Exception was thrown by user callback. Error: permission_denied at ...." and this becomes an actual exception. While I do expect to see this behavior, what are the best practices for logging a user out so I don't see this warning/exception? 回答1: I had the same problem. Through the following source, I found a solution so far,

Firebase $id from second level Object

左心房为你撑大大i 提交于 2019-12-05 18:17:02
So I have this for example in firebase clients { //clients with unique keys { invoices: { // Invoices with unique Keys } } } I'm returning all this with one ref like so: .controller('singleClientController', function($scope, $firebaseObject, fbUrl, $routeParams) { var id = $routeParams.id; var singleRef = new Firebase(fbUrl+'/clients/'+id); var client = this; client.details = $firebaseObject(singleRef); }) so in my html, I'm trying to return the $id for both the client and the invoice. I am able to get the client no problem with {{client.details.$id}} but when I try to do the same thing with

Property 'filter' does not exist on type 'FirebaseListObservable'

爱⌒轻易说出口 提交于 2019-12-05 16:28:33
I am using Ionic 2 and Firebase to build a chat app. I add the following which is supposed to be used to add a filter: import 'rxjs/add/operator/filter'; ... public af: AngularFire ... this.firelist = this.af.database.list('/chat/', { query: { orderByChild: 'negativtimestamp' } }).filter(item => item.memberIds === 'xxx'); However, I get the following: [ts] Property 'filter' does not exist on type 'FirebaseListObservable'. ps. this.af.database.list(...) returns a FirebaseListObservable<any[]> . filter can be done on Observable but not on FirebaseListObservable . Question So how do I implement