I'm extending the back office with a new section to hold custom form data. My controller code is as below and everything is working fine, however what I would like to do is once the save method has been called redirect the user to the edit page for the newly created form in the same manner as when creating a new macro. I'm assuming that this is done using the navigationService however I have no idea how to go about it. Anyone got any tips?
angular.module("umbraco").controller("MyForm.MyFormCreateController",
function ($scope, $routeParams, contactFormResource, notificationsService, navigationService) {
$scope.loaded = true;
$scope.form = {};
$scope.save = function (form) {
contactFormResource.save(form).then(function (response) {
$scope.form = response.data;
navigationService.syncTree({ tree: "contactForms", path: [-1, -1], forceReload: true });
notificationsService.success("Success, the form ", form.Name + " has been saved");
});
};
});
at the end of the save function and whilst the url is changing in the address bar it doesn't actually load the content and raises an error about unsaved changes?
Custom tree help
I'm extending the back office with a new section to hold custom form data. My controller code is as below and everything is working fine, however what I would like to do is once the save method has been called redirect the user to the edit page for the newly created form in the same manner as when creating a new macro. I'm assuming that this is done using the navigationService however I have no idea how to go about it. Anyone got any tips?
Hi Patrick,
don't think you can use the navigationService for that.
I change the window.location with the path to the edit page in a custom section I build.
Regards David
Thanks for the quick reply David, I tried adding
at the end of the save function and whilst the url is changing in the address bar it doesn't actually load the content and raises an error about unsaved changes?
Hi Patrick,
think that is because your Form in the page is marked as $dirty from angular. This prevents umbraco from changing the view.
Maybe you can check that?
Regards David
Thanks for your help David, got me looking in the right direction. I ended up resetting the dirty flag on my form and then using
and its now all working as expected.
is working on a reply...