background preloader

Forms/Validation Tuts

Facebook Twitter

Enhance Required Form Fields with CSS3. Natural Language Form.

User Authentication/Password Forms

Form Validation. The concepts of AngularJS Forms. Creating HTML form is quite easy for developers like us and I’m sure we don’t need to talk it again here since there are plenty of HTML form tutorial out there.

The concepts of AngularJS Forms

Don’t worry we are not going to talk about plain HTML form, we are going to understand form in the context of Angular. Your understanding of plain HTML form will be a prequisite here. This article also requires basic angular knowledge, If you don’t have any idea what angular is, you should read my post on angular overview first before continuing. The goal of an application is to help people, by using an application people or users want to accomplish their tasks.

For example people use browser to surf the internet, people use video player to watch their favorite movies. More nested Forms. Fmatosic/bubblemevalid. The ngForm directive of AngularJS. I go back to talk about form validation with AngularJS.

The ngForm directive of AngularJS

Lately, I had to work with a form created dynamically on the basis of a JSON response, that I get from the server. In this case the approach is a bit different from the one I discussed in my first post about form validation with AngularJS. So what I had was something like (in the following code for the sake of brevity, I will consider a simplified scenario where the form consists of only input fields of type text): <form name="signForm" ng-controller="FormController" novalidate><div ng-repeat="f in fields"><input type="text" name="{{}}" ng-required="f.isRequired"/><div ng-show="signForm[]. $dirty && signForm[]. Where fields is defined in the controller.

But sadly the validation didn’t work. Forms in AngularJS. Forms With AngularJS. Continuing to reach for feature parity with my original jQuery with ASP.NET Web API sample, I need to have the ability to create a new video.

Forms With AngularJS

The original sample caught the form submit event and serialized form data for an AJAX submission to the web server. With AngularJS I only need to bind some form elements to the model (using the ng-model directive), and bind a click event (with the ng-click directive). Note there is also an ngSubmit directive, but Angular will prevent the default form submission if I have only one or the other. When the user clicks save, I just need to post the new video information to the Web API. The controller code now looks like the following: Notice it is easy to keep private methods and data inside a controller. Next I need the ability to delete and edit existing videos, and then the sample will behave exactly like the original "jQuery only" sample. A Reusable Bootstrap Modal AngularJS Directive for Forms - Panther Software. Getting Started – The Form Directive.

A Reusable Bootstrap Modal AngularJS Directive for Forms - Panther Software

My basic goal is to create an AngularJS Directive that: presents a consistent ui interface has configurable attributes for the form’s submit, cancel, title and body content modals are instantiated and displayed when required via a click event. Forms-angular. Empty Fiddle. Form Builder. Plunker. Adding and Removing Children with Rails Nested Forms and AngularJS. AngularJS had appeared on my radar before, but I wasn’t inspired to try it until I read Click to Edit with AngularJS by Tim Riley.

Adding and Removing Children with Rails Nested Forms and AngularJS

AngularJS takes a different approach to enhancing pages. Instead of thinking about DOM manipulation, you think about data and bindings. We have a project at work that has nested forms. You can add and remove children before saving the entire object graph. We also have a rule where you cannot remove a child if there is only one child. I’ll start by giving context, and then break everything down line by line. . # app/models/plan.rb class Plan < ActiveRecord : :Base has_many :polls accepts_nested_attributes_for :polls end In the Rails controller we setup a default poll. # app/controllers/plans_controller.rb class PlansController < ApplicationController def new @plan = Plan . new @plan . polls . build title : 'Time' end end Then we write the view. And the AngularJS controller. You really need to try this jsfiddle to see it in action .