angular-patternfly
angular-patternfly copied to clipboard
Improve pf-wizard validation
Original issue in origin-web-console.
The example in the original issue is this:
var validityWatcher;
// ...
// in a setup fn:
validityWatcher = $scope.$watch("ctrl.selectionForm.$valid", function(isValid) {
ctrl.steps[0].valid = isValid;
});
// ...
// in another fn:
if (validityWatcher) {
validityWatcher();
validityWatcher = undefined;
}
//
// in a cleanup fn:
ctrl.$onDestroy = function() {
if (validityWatcher) {
validityWatcher();
validityWatcher = undefined;
}
// ...
There is a lot of bookkeeping involved for validation & it feels a bit out of sync with typical angular validation. The ideal option is to get it in the view, but a secondary option might be to get a validation function added to the steps & hide the setup/tear down code from the user (hide by adding an ng-form behind the scenes, perhaps w/a name = to the step.id or step.id+rand and then toggling its $valid property based on the validator fn).