0
Good afternoon, Guys, I’m trying to create a Factory with firebase, to bring the data from it.
My controller:
app.controller('ListagemCtrl', function($scope, $location, $firebaseObject, $timeout, appFactory){
$scope.filmesCadastrados = [];
appFactory.pegaFilmes().on('value', function (snapshot) {
    for(var id in snapshot.val()){
        var filme = snapshot.val()[id];
        $scope.filmesCadastrados.push({
            titulo: filme.titulo,
            diretor: filme.diretor,
            categoria: filme.categoria,
            duracao: filme.duracao
        });
    }
});
});
And this is my Factory:
app.factory('appFactory', function($scope, $firebaseObject){
var _pegaFilmes = function() {
    return firebase.database().ref('filmes/').on('value', function (snapshot) {
                for(var id in snapshot.val()){
                    var filme = snapshot.val()[id];
                    //console.log(filme);
                    $scope.filmesCadastrados.push({
                        titulo: filme.titulo,
                        diretor: filme.diretor,
                        categoria: filme.categoria,
                        duracao: filme.duracao
                    });
                }
            });
}
return {
    pegaFilmes: _pegaFilmes
};
});
This warning appears on the console:
angular.js:13708 Error: [$injector:unpr] http://errors.angularjs.org/1.5.7/$injector/unpr? P0=copeProvider%20%3C-%20%24scope%20%3C-%20appFactory
I’m gonna try, thanks.
– GustavoSevero
What a show!!! It worked!! It was worth a lot
– GustavoSevero
Paulo, how do I get a property from Firebase data? Type, I want to take one of the elements of the json object, example, just the title of the movie.
– GustavoSevero
That’s all you need, I’ve got it.
– GustavoSevero