案例:AngularJS案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<meta charset="utf-8">
5
<script src="/js/angular.js1.4.6/angular.min.js"></script>
6
</head>
7
<body>
8
9
<div ng-app="myApp" ng-controller="personCtrl">
10
11
<button ng-click="toggle()">隐藏/显示</button>
12
13
<p ng-show="myVar">
14
名: <input type=text ng-model="person.firstName"><br>
15
姓: <input type=text ng-model="person.lastName"><br><br>
16
姓名: {{person.firstName + " " + person.lastName}}
17
</p>
18
19
</div>
20
21
<script>
22
var app = angular.module('myApp', []);
23
app.controller('personCtrl', function($scope) {
24
    $scope.person = {
25
        firstName: "John",
26
        lastName: "Doe"
27
    };
28
    $scope.myVar = true;
29
    $scope.toggle = function() {
30
        $scope.myVar = !$scope.myVar;
31
    };
32
});
33
</script>
34
35
</body>
36
</html>
37