Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
AngularJS Web Application Development Blueprints

You're reading from   AngularJS Web Application Development Blueprints A practical guide to developing powerful web applications with AngularJS

Arrow left icon
Product type Paperback
Published in Aug 2014
Publisher Packt
ISBN-13 9781783285617
Length 300 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Vinci J Rufus Vinci J Rufus
Author Profile Icon Vinci J Rufus
Vinci J Rufus
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Introduction to AngularJS and the Single Page Application 2. Setting Up Your Rig FREE CHAPTER 3. Rapid Prototyping with AngularJS 4. Using REST Web Services in Your AngularJS App 5. Facebook Friends' Birthday Reminder App 6. Building an Expense Manager Mobile App 7. Building a CMS on the MEAN Stack 8. Scalable Architecture for Deployments on AWS 9. Building an E-Commerce Store A. AngularJS Resources Index

Building the Add Expense form


Now, let's create our Add Expense form. We will add the following code in the app/partials/add-expense.html file:

<h2>Add Expense</h2>
<form id="addForm" name="addForm" novalidate >
    <label>Category</label>
    <select ng-model="expense.category" ng-options="category for category in categories">
    </select>
    <label>Amount:</label>
    <input type="number" ng-model="expense.amount"></input>
    <label>Description:</label>
    <input type="text" ng-model="expense.description"></input>
    <button ng-click="submit()">Submit</button>
</form>

This is a rather straightforward form. The novalidate tag in HTML5 is used to disable the browser's default validations.

Notice that we are also making use of the built-in directive, ng-options, to dynamically load the category list into our select box.

We'll style the form by adding the following CSS to the app/css...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime