Angularfire crashes browser when saved

Asked

Viewed 90 times

0

Hello,

I’m running some tests on Angularfire, and every time I save an object at the base, the browser crashes. The screen is even updated but I have to stop running the tab and refresh the page so that the browser works properly again.

Would anyone know what might be causing the problem?

Navegador travado

Below the controller code when saving the object.

angular.module("AlbionTrading").controller("indexCtrl", function ($scope, $firebaseObject, $firebaseArray) {

//Pega objeto direto no Firebase
var ref = firebase.database().ref('AppSettings/');
// download the data into a local object
var syncObject = $firebaseObject(ref);
// synchronize the object with a three-way data binding
// click on `index.html` above to see it used in the DOM!
syncObject.$bindTo($scope, "appName");


//Pega array de objetos no Firebase
var cities = firebase.database().ref('Cities/');
$scope.cities = $firebaseArray(cities);

var posts = firebase.database().ref('Posts/');
$scope.posts = $firebaseArray(posts);


$scope.adicionarPost = function (post) {
    console.log(post);
    $scope.posts.$add({
        Cidade: post.Cidade.Name,
        Text: post.Text
    });
    delete $scope.post;
    $scope.postForm.$setPristine();
}

});

  • Open the browser console, see if an error appears there. Must be giving stackoverflow and it is no pun with the name of the site, hehehe.

  • Hello Douglas, I tested again but nothing appeared on the console, only the very object I am saving that I had written on the console to check.

1 answer

0

I would like to share the solution to the problem.

Apparently it was something in relation to angularfire lib that causes browser locking(either I was doing wrong or internal lib problem).

I used 'direct' as the documentation of Firebase itself teaches. Follows code below:

$scope.adicionarPost = function (post) {
    console.log(post);
    posts.push({
        Cidade: post.Cidade.Name,
        Text: post.Text
    });
    delete $scope.post;
    $scope.postForm.$setPristine();
}

Code snippet from post add function.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.