Angularjs Study Chapter II (ANGULARJS expression)

Source: Internet
Author: User

ANGULARJS-expression

The ANGULARJS expression is written in double curly braces:{{expression}}

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

Angularjs will "output" data where the expression is written

Angularjs is much like a JavaScript expression: He can contain literals, operators, and variables

Instance:

<! DOCTYPE html> <html> <head> < Span class= "hl-brackets" > <meta charset= "utf-8 "> < Span class= "Hl-code" > <script src= " Http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js> < Span class= "hl-quotes" > < Span class= "Hl-code" > </script > < Span class= "Hl-code" > </head> < Span class= "Hl-code" > <body < div ng-app= "" > <p> my first expression: </p> </div> < Span class= "hl-brackets" > </body> </html> Output: My first expression: 10AngularJS application Angularjs Module ( Moudule) for ANJULARJS applications Ng-appDirectives define the application, Ng-controllerDefines the controller. Angularjs instances:

<! DOCTYPE html>
<meta charset= "Utf-8" >
<script src= "Http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js" ></script>
<body>

<p> try to modify the following form. </p>

<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>
var app = angular.module('myApp', []);
App.controller (' Myctrl ', function ($scope) {
$scope. Firstname= "John";
$scope. Lastname= "Doe";
});
</script>

</body>

ANGULARJS module definition application:

ANJULARJS Module

var app = angular.module (' myApp ', []);

ANGULARJS controller Control applications:

ANJULARJS Controller:

App.controller (' Myctrl ', function ($scope) {

$scope. FirstName = "John";

$scope. LastName = "Doe";

})

Angularjs Study Chapter II (ANGULARJS expression)

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.