Angularfire crashes browser when saved

0

Hello,

I'm doing tests on Angularfire, and every time I save an object to the base, the browser crashes. The screen is up to date but I have to stop the execution of the tab and refresh the page for the browser to work properly again.

Would anyone know what might be causing the problem?

Belowthecontrollercodewhensavingtheobject.

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();
}

});

    
asked by anonymous 30.03.2017 / 22:01

1 answer

0

I would like to share the solution to the problem.

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

I used it 'direct' as the documentation the Firebase itself teaches. Here is the code below:

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

Add-in function code snippet.

    
07.04.2017 / 13:50