I would create a server side request for a new Proveedore, and that function can generate and return a new unused number.
To generate a new number you can do that a couple of different ways:
1: generate a random number and see if it exists in the database. If it does generate another and test, repeat until you find an unused number.
2: Generate a random number and if it exists increment that number by one and test if that exists. Repeat incrementing and testing until you find one that doesn't exist.
There are other ways also. If you don't need a random number then you could restart numbering at the lowest allowed, such as 1, and test if it's available. Increment until you find an unused one. Then save this for the next request.
After your function finds an used number return that to the client - browser.
Server side would be done in Laravel (php).
AngularJS browser side would be a simple http.get request, depending on the structure of your code you would do something like:
$http.get('/api/newproveedore)
.success(function(data) {
$scope.proveedore = data;
})
.error(function(data) {
console.log('Error: ' + data);
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…