What i am trying to now do is when the user clicks 'save and publish' make an ajax call (through a service) to a web api. depending on what is returned i will then set the $scope.model.value to a value for umbraco to automagically save it.
to do this i have hooked into the method $scope.$on("formSubmitting", function (ev, args) {....} in my controller. This is the only way I know of doing this is there any other?
The problem is that by the time the ajax call returns umbarco has already saved the $scope.model.value value. is there a way of forcing the $scope.$on method to wait on the ajax request returning before saving. If not how would you go about implementing this process.
alert("Alert email was not sent please try again!!");
}
});
}
})
});
heres the html-----
isapprovedResource.SendIsApprovedEmail is a service that returns "OK" as a string.
basically this saves a json string like { "approved": false, "confirmationEmail": false } to the cmsPropertyData table. once the email has been sent confirmationEmail = true and it wont be sent again.
angularjs property editor problem
Hi All,
ive created a property editor using angualrjs.
What i am trying to now do is when the user clicks 'save and publish' make an ajax call (through a service) to a web api. depending on what is returned i will then set the $scope.model.value to a value for umbraco to automagically save it.
to do this i have hooked into the method $scope.$on("formSubmitting", function (ev, args) {....} in my controller. This is the only way I know of doing this is there any other?
The problem is that by the time the ajax call returns umbarco has already saved the $scope.model.value value. is there a way of forcing the $scope.$on method to wait on the ajax request returning before saving. If not how would you go about implementing this process.
thanks
lj
Hi lj
Could you perhaps share your full code? I think it can perhaps speed up things if people can see the context.
Cheers, Jan
hi there,
here you go.
controller ----
angular.module("umbraco").controller("IsApprovedController", function ($scope, isapprovedResource, $routeParams) {
var confirmationEmail = false;
if ($scope.model.value.confirmationEmail != '' && $scope.model.value.confirmationEmail == true) {
confirmationEmail = true;
}
if ($scope.model.value.approved != '' && $scope.model.value.approved == true) {
$scope.model.approved = true;
}
else {
$scope.model.approved = false;
}
//$scope.change = function () {
//};
$scope.$on("formSubmitting", function (ev, args) {
$scope.model.value = { approved: $scope.model.approved, confirmationEmail: confirmationEmail };
console.log(confirmationEmail); console.log(' 2');
if ($scope.model.approved && !confirmationEmail) {
//user has approved for the first time so send confirmation email and set flag
isapprovedResource.SendIsApprovedEmail($routeParams.id).then(function (response) {
if(response.data == '\"OK\"')
{
confirmationEmail = true;
$scope.model.value = { approved: $scope.model.approved, confirmationEmail: confirmationEmail };
console.log(confirmationEmail); console.log(' 1');
}
else {
alert("Alert email was not sent please try again!!");
}
});
}
})
});
heres the html-----
isapprovedResource.SendIsApprovedEmail is a service that returns "OK" as a string.
basically this saves a json string like { "approved": false, "confirmationEmail": false } to the cmsPropertyData table. once the email has been sent confirmationEmail = true and it wont be sent again.
thanks
lj
Hi lj,
I think Umbraco uses angular js validation for forms validation: http://docs.angularjs.org/guide/forms
Alain
is working on a reply...