My current challenge involves creating an object with a defined name, posting it into a database, and then immediately finding its position and obtaining its id. However, I have noticed that using "get" right after "post" retrieves the data before it's even posted. How can I update the database before retrieving the data? Any suggestions would be greatly appreciated. Thank you!
/*controller createCtrl*/
outbox.controller('createCtrl',function($scope,$http,$filter,$window){
console.log("In create control.");
$scope.create = function(name){
var a=$scope.name;
console.log(a);
var newmodel={name:a,};
/*Post new model*/
var urlpost = restURL+'/service/repository/models?size=50';
console.log(urlpost);
$http.post(urlpost,newmodel)
.success(function (response, status, headers, config) {
console.log(status);
$scope.model = response.data;
})
.error(function(response, status, headers, config){
console.log(response.error_message);
$scope.error_message = response.error_message;
});
/*get the databese*/
$http.get(urlpost,reqConfig)
.success(function (response, status, headers, config) {
console.log(status);
$scope.models=response.data;
console.log(response.data);
console.log(a);
var w=$filter('filter')(response.data,{name:newmodel.name},true);
console.log(w);
var urllink="rootURL+modeler.html?modelId="+w[0].id;
console.log(urllink);
$window.open(urllink);
})
.error(function(response, status, headers, config){
console.log(response.error_message);
$scope.error_message = response.error_message;
});
};
});