ANGULARJS Basic Ng-model instructions and sample code _ANGULARJS

Source: Internet
Author: User
Tags html form


Angularjs Ng-model Instruction



Angularjs instance



The value of the bound input box to the scope variable:


<! DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<script src = "http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"> </ script>
</ head>
<body>

<div ng-app = "myApp" ng-controller = "myCtrl">

<input ng-model = "name">

<p> The value of the input box is bound to the variable "name": </ p>
{{name}}

</ div>

<script>
var app = angular.module ('myApp', []);
app.controller ('myCtrl', function ($ scope) {
   $ scope.name = "John Doe";
});
</ script>

<p> This example demonstrates how to use the ng-model directive to bind the value of the input box to the scope variable. </ p>

</ body>
</ html> 


Definitions and usage



The ng-model directive binds an HTML form element into a scope variable.



If a variable does not exist in scope, it will be created.



Grammar



<element ng-model= "Name" ></element>



<input>, <select>, <textarea>, the element supports the directive.



Parameter values





value Description
Separator You want to bind to the form field's property name.





The above is the Angularjs Ng-model data collation, follow-up continue to supplement the relevant information.


Related Article

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.