php – How to check if data already exists in the database before inserting another in angular?


I have already made a modal that receives a name, it sends it to the controller in the function of inserting a new contact. I want to check if this data is already registered in the bank so that they don't register 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 == ?? )


I believe that the best way would be to do this at the time of inserting and through and only your backend code to check if it already exists, if not, insert

Scroll to Top