Skip to content

Commit

Permalink
Merge pull request #470 from guardian/fp/fix-commissioned-length-erro…
Browse files Browse the repository at this point in the history
…r-on-submit

Fix error: [ngModel:numfmt] Expected `N` to be a number
  • Loading branch information
Fweddi authored Oct 21, 2024
2 parents f5b3d4e + eda7e87 commit 7d4ed55
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions public/components/stub-modal/stub-modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ <h4 class="modal-title">{{ modalTitle }}</h4>
class="form-control"
name="commissionedLength"
type="number"
string-to-number
ng-model="stub.commissionedLength"
placeholder="Choose a custom commissioned length"
/>
Expand Down
17 changes: 15 additions & 2 deletions public/components/stub-modal/stub-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ wfStubModal.run([
mode: () => mode
}
});
};
}
}]).directive('wfFocus', ['$timeout', function($timeout){
return {
restrict: "A",
Expand All @@ -510,4 +510,17 @@ wfStubModal.run([
}
}
};
}]);
}]).directive('stringToNumber', function() {
return {
require: 'ngModel',
link: function(scope, element, attrs, ngModel) {
ngModel.$parsers.push(function(value) {
return '' + value;
});
ngModel.$formatters.push(function(value) {
return parseFloat(value);
});
}
};
});

0 comments on commit 7d4ed55

Please sign in to comment.