Static Spring boot Application hosting a basic AngularJS
custom form input validation example taken from AngularJS Form Validation article. It does default required atteribute validation on first input, the local Javascript function validation on the second input, toggling the $valid property of the input and of the form through $parsers, and does a remote rest call to validate the third input, also togling the similar propery but through updating the $asyncValidators depednency injected propery.
the controller rule will override the existing static page:
add src/main/resourcses/static/page.html
and endpoint
@ResponseBody
@GetMapping("/page")
public String getPage() {
return "page is here";
}then
curl http://192.168.0.64:8080/page.html
will return the text produced by controller:
page is here
mvn -Ddebug=true -Dapplication=application testThe debug flag will trigger printing additional debugging information
mvn clean -Dmaven.test.skip=true spring-boot:runfollowed by opening in the browser http://localhost:8080/input-validation.html
this will show form with two inputs, validated. Only the second validation tiggels the button
console.log('response: '+ JSON.stringify(mCtrl));leads to
TypeError: Converting circular structure to JSON
property '$$controls' -> object with constructor 'Array'
| index 0 -> object with constructor 'Object'
--- property '$$parentForm' closes the circle
console.log('response: '+ JSON.stringify(scope.form2.username));leads to
TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Object'
| property '$$parentForm' -> object with constructor 'Object'
| property '$$controls' -> object with constructor 'Array'
--- index 0 closes the circle
-
AngularJS Form $setValidity post
-
form.FormControllerdocumentation -
https://stackoverflow.com/questions/14363656/using-setvalidity-inside-a-controller
-
https://stackoverflow.com/questions/31875248/how-to-pass-the-input-element-as-a-parameter-in-ng-blur
-
https://www.itsolutionstuff.com/post/angular-input-blur-event-exampleexample.html
-
https://stackoverflow.com/questions/24336858/pass-http-from-controller-to-directive
-
https://stackoverflow.com/questions/22142017/angular-directive-handles-http-request
-
https://stackoverflow.com/questions/14363656/using-setvalidity-inside-a-controller
-
https://stackoverflow.com/questions/42964908/accessing-scope-from-a-directive-in-angularjs
-
https://stackoverflow.com/questions/30947808/how-to-get-the-value-of-a-field-with-ng-change
-
https://stackoverflow.com/questions/27923529/asyncvalidators-angular
-
$asyncValidatorsangularjs documentation (a full reading is required) -
$parsersangularjs documentation (a full reading is required)
