- Angular helps create responsive (as in fast) websites.
- Angular plays well with jQuery.
- Angular is easy to test.
A “responsive “website using Angular
What is Angular JS?
- Where we write pieces of our Angular application.
- Makes our code more maintainable, testable, and readable.
- Where we define dependencies for our app.
Allow you to insert dynamic values into your HTML.
Controllers are where we define our app?s behavior by defining functions and values.
Using Angular Expressions inside a src attribute causes an error! Because the browser tries to load the image before the Expression evaluates.
ng-model binds the form element value to the property.
So we can have live previrew.
Two More Binding Examples
We don?t want the form to submit when it?s invalid.
Turn Off Default HTML Validation
novalidate: Turn Off Default HTML Validation
required: Mark Required Fields
Preventing the Submit
If valid is
false , then
addReview is never called.
Doesn?t Submit an Invalid Form
How might we give a hint to the user why their form is invalid?
Source before typing email1<input name="author" . . . class="ng-pristine ng-invalid">
Source after typing, with invalid email1<input name="author". . . class="ng-dirty ng-invalid">
Source after typing, with valid email1<input name="author" . . . class="ng-dirty ng-valid">
HTML5-based type validations
Web forms usually have rules around valid input:
- Angular JS has built-in validations for common input types: