Angularjs Getting Started form development

Source: Internet
Author: User

This article and we share the main is the front-end development of the necessary AngularJs Framework form development related basic knowledge, want to use and learn from everyone AngularJs helpful.

1. simple form submission;

2. more form elements;

3. initialize the form;

Code

<!doctype html>

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">

<title>

LESSON 7

</title>

<link rel= "stylesheet" type= "Text/css" href= "Css/main.css"/>

<style>

#content1 {padding:16px;}

</style>

<body>

<form ng-submit= "Postform ()" >

<ul>

<li>

<label> Username:</label><input type= "text" ng-model= "form. UserName "/>

</li>

<li>

<label> Nickname:</label><input type= "text" ng-model= "form. Nickname "/>

</li>

<li>

<label> Age:</label><input type= "text" ng-model= "form. Age "/>

</li>

<li>

<label> is married:</label><input type= "checkbox" ng-model= "form. Ismarried "/>

</li>

<li>

<label> favorite Animals:</label>

<input type= "Radio" ng-model= "form. Lovedanimal "value=" dog "/> Dog "

<input type= "Radio" ng-model= "form. Lovedanimal "value=" cat "/> cat

</li>

<li>

<label> City of residence:</label>

<select ng-model= "form. Locationcity "

Ng-options= "Obj.text as Obj.value for obj in form. Locationcitylist "

>

<option value= "" > Please select City </option>

</select>

</li>

<li>

<input type= "Submit" value= " submission " />

</li>

</ul>

</form>

<ul>

<li>{{form. Username}}</li>

<li>{{form. Nickname}}</li>

<li>{{form. Age}}</li>

<li>{{form. Ismarried}}</li>

<li>{{form. Lovedanimal}}</li>

<li>{{form. Locationcity}}</li>

</ul>

<script src= "Scripts/angular-1.4.6.min.js" ></script>

<script>

var app = Angular.module ("Lesson", []);

App.controller ("Formctrl", function ($scope) {

$scope. forminitobj = {

UserName: "",

Nickname: "",

};

$scope. form = {};

$scope. form.locationcitylist = [

{text: " Beijing " , Value: " Beijing "},

{text: " Shanghai " , Value: " Shanghai "},

{text: " Guangzhou " , Value: " guangzhou "}

];

$scope. Postform=function () {

Console.log ($scope. form);

$scope. Form = Angular.copy ($scope. forminitobj);

}

});

</script>

</body>

Execution results

original link:http://www.maiziedu.com/wiki/angularjs/develop/

Angularjs Getting Started form development

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.