0

I'm integrating firebase with AngularJS, and I'm having some trouble using the result of a firebase snapshot in a promise.

Below is the code in one of my states in ui-router:

                resolve: {
                    opinionConfig: function($stateParams, $location, $q, ConstantsService) {
                        var result = $q.defer();
                        var processResponse = function(value) {
                            value.opinion = $stateParams.opinion;
                            result.resolve(value);
                        };

                        var rootRef = new Firebase(ConstantsService.FIREBASE_URL + 'configs/' + $stateParams.opinion);

                        rootRef.once('value', function(snapshot) {
                            if (snapshot.val() === null) {
                                $location.path('/');
                                // console.log("configs doesn't exist.");
                                result.reject("configs doesn't exist");
                            } else {
                                // console.log("configs does exist: " + snapshot.val());
                                processResponse(angular.copy(snapshot.val()));
                            }
                        });

                        return result.promise;
                    }
                }

and I'm getting this error in firefox's developer tools.

enter image description here

and this is what I get in Chrome's developer tools.

enter image description here

It seems like the two errors are different, and I couldn't find an official un-minified version of firebase.js, so I wasn't sure where exactly this is being thrown.

Thanks,

Luke

1 Answer 1

1

You are using min version of js (the error says angular.min...)

and then this

opinionConfig: function($stateParams, $location, $q, ConstantsService) {

is converted into this

opinionConfig: function(c, x, g, r) { // an example showing minification

so what we have to do is:

opinionConfig: 
['$stateParams', '$location', '$q', 'ConstantsService',
function($stateParams, $location, $q, ConstantsService) {

maybe check also this Minified AngularJS gives me unreadable errors

Sign up to request clarification or add additional context in comments.

6 Comments

I'm getting the same error even after escaping the injections.
Then you have to search for more declarations like this... That is my 99,9% suspected...
If I just return a normal object without changing the signature. There's no error. I suspect it might be the promise issue. I also uploaded the error i see in Chrome.
Gb really could come from minified version of the firebase, but the issue I see, is that the Gb is not found on the null... so it would be on our (not firebase) side... could you create a plunker?
Okay. Let me create one.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.