Angular JS Introduction

Source: Internet
Author: User

---restore content starts---

1: Add a anjular.js file to the HTML page via the <script> tag (it is recommended to place the script at the bottom of the BODY element)

the AngularJS property isng-start, but you can use thedata-ng-to make the Web page valid for HTML5.

2: Common Angular JS directives (instruction)

Ng-app: The directive defines an angular JS application. If you removeNg-appinstruction, HTML will display the expression directly and will not evaluate the result of the expression.

ng-model: Command bar element from (such as input field value) bound to the application

Ng-bind: Command bar Application Data binding to HTML view: The BIND data Direct output directive binds the application variable name to the InnerHTML of a paragraph.

Ng-init: Instruction initialization angular JS application variable

Ng-controller,

Ng-show:

3:angular JS Expression

Angular JS expression is written in double curly braces {{expression}}

Angular JS expression binds data to HTML, which is similar to the Ng-bind directive

Angular JS will "output" data at the position where the expression is written

Angular js expressions and JavaScript expressions: They can contain text, arithmetic, and variables. For example {{5 + 5}} or {{firstName + "" + LastName}}

4:angular JS Application

Angular JS Modules (module) defines the application of Angular JS

Angular JS Controller for controlling Angular is the application

The NG-NPP directive defines the application and Ng-controller defines the controller



HTML5 allow extended (self-made) properties to start with data-
Pasting

<! DOCTYPE html>


<meta charset="Utf-8">
<script src="Http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>

<body>

<div ng-app="">
<p> Name: <input type="text"Ng-model="name"></p>
</div>

</body>


<div ng-app= "" ng-init= " firstname= ' John ' " >

<p> name is <span ng-bind="FirstName"></span></p>

</div>


Application of Angular JS

<div ng-app="myApp"ng-controller="Myctrl">
Name: <input type="text"Ng-model="FirstName"><br>
Surname: <input type="text"Ng-model="LastName"><br>
<br>
Name: {{firstName +" "+ LastName}}

</div>

<script>//
varApp = Angular.module ('myApp', []);//anggular JS Module
App.controller ('Myctrl', function ($scope) {//anjular JS Controller
$scope. firstname="John";
$scope. lastname="Doe";
});
</script>

Angular JS Introduction

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.