实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<body>
4
5
<div ng-app="" ng-controller="personController">
6
7
名: <input type="text" ng-model="person.firstName"><br>
8
姓: <input type="text" ng-model="person.lastName"><br>
9
<br>
10
姓名: {{fullName()}}
11
12
</div>
13
14
<script>
15
function personController($scope) {
16
    $scope.person = {
17
        firstName: "John",
18
        lastName: "Doe",
19
    };
20
    $scope.fullName = function() {
21
        var x = $scope.person;  
22
        return x.firstName + " " + x.lastName;
23
    }
24
}
25
</script>
26
27
<script src="//www.shouce.ren/try/angularjs/1.2.5/angular.min.js"></script>
28
29
</body>
30
</html>
31