Book Image

AngularJS Web application development Cookbook

By : Matthew Frisbie
Book Image

AngularJS Web application development Cookbook

By: Matthew Frisbie

Overview of this book

Packed with easy-to-follow recipes, this practical guide will show you how to unleash the full might of the AngularJS framework. Skip straight to practical solutions and quick, functional answers to your problems without hand-holding or slogging through the basics. Avoid antipatterns and pitfalls, and squeeze the maximum amount out of the most powerful parts of the framework, from creating promise-driven applications to building an extensible event bus. Throughout, take advantage of a clear problem-solving approach that offers code samples and explanations of components you should be using in your production applications.
Table of Contents (17 chapters)
AngularJS Web Application Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Working with AngularJS forms


AngularJS offers close integration with HTML form elements in the form of directives to afford you the ability to build animated and styled form pages, complete with validation, quickly and easily.

How to do it…

AngularJS forms exist inside the <form> tag, which corresponds to a native AngularJS directive, as shown in the following code. The novalidate attribute instructs the browser to ignore its native form validation:

<form novalidate>
  <!-- form inputs -->
</form>

Your HTML input elements will reside inside the <form> tags. Each instance of the <form> tag creates a FormController, which keeps track of all its controls and nested forms. The entire AngularJS form infrastructure is built on top of this.

Tip

As browsers don't allow nested form tags, ng-form should be used to nest forms.

What the form offers you

Suppose you have a controller; a form in your application is as follows:

<div ng-controller="Ctrl">
  <form novalidate...