AngularJs表達式html
AngularJs表達式寫在雙大括號內:{{expression}}express
AngularJS表達式把數據綁定到HTML,與ng-bind指令有 殊途同歸之妙app
AngularJS將在表達式書寫的位置「輸出」數據spa
AngularJS很像JavaScript表達式:他能夠包含文字、運算符和變量code
實例:cdn
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>
<body>htm
<p>嘗試修改如下表單。</p>ip
<div ng-app="myApp" ng-controller="myCtrl">utf-8
名: <input type="text" ng-model="firstName"><br>
姓: <input type="text" ng-model="lastName"><br>
<br>
姓名: {{firstName + " " + lastName}}input
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.firstName= "John";
$scope.lastName= "Doe";
});
</script>
</body>
</html>
AngularJS模塊定義應用:
AnjularJS模塊
var app = angular.module('myApp',[]);
AngularJS控制器控制應用:
AnjularJS控制器:
app.controller('myCtrl',function($scope){
$scope.firstName = "John";
$scope.lastName = "Doe";
})