How to check if data already exists in the bank before inserting another in angular?

4

I have already made a modal that receives a name, it sends the controller in the function of inserting new contact. I want to check if this data is already registered in the bank so they do not sign it again. Anyone know how I can do this in AngularJS?

I've done this so far ...

//Carrega as categorias existentes

 var carregaCategorias = function(){
            var tam = $scope.categoria.length;
            for (var i = 0; i < tam; i++)
                $scope.categorias[i] = $scope.categoria[i].nome;
        }

//Verifica se já está inserido

$scope.createCategory = function(typeOfCategory, modalId){ //OK

            var typeCategory;
            var category = $scope.novaCategoria;

            if(category == ?? )
    
asked by anonymous 07.05.2018 / 19:45

1 answer

0

I think the best way would be to do this at the very time of inserting and through and only of your backend code to do this check if it already exists, if it does not exist

    
16.10.2018 / 22:32