Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Info

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.

Page

NOTE:

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

Testing

mvn -Ddebug=true -Dapplication=application test

The debug flag will trigger printing additional debugging information

Running

mvn clean -Dmaven.test.skip=true spring-boot:run

followed 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

Note

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

See Also

Author

Serguei Kouzmine