Set form to submitted once it's loaded

78 Views Asked by At

I am trying to submit the form initially but when I try to do vm.form.$setSubmitted();, vm.form is still undefined at that point as it takes a while to load. How can I submit the form once it stops being undefined?

I have written this sort of $watcher but doesn't work.

$scope.$watch(vm.form, function(newValue, oldValue) {
    if(newValue !== oldValue) {
        vm.form.$setSubmitted();
    }
});

Or maybe there's a more appropriate way I'm unaware of.

0

There are 0 best solutions below