-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathone-vs.html
84 lines (75 loc) · 1.9 KB
/
one-vs.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!DOCTYPE HTML>
<html>
<head>
<title>JS vs NG</title>
<meta charset="UTF-8">
<style type="text/css">
pre span { background-color: lightblue; }
p { font-family: courier, sans-serif; }
.leftCol { padding-right: 50px; border-right: 1px dashed silver; }
</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
</head>
<body>
<p><script type="text/javascript">document.write(location.href)</script></p>
<table>
<tr>
<th>Javascript</th>
<th>Angular</th>
</tr>
<tr>
<td valign="top" class="leftCol">
<pre>
<span><!doctype html>
<html></span>
<span><body></span>
<div>
Name: <input id="inputFirstname" value="John">
<h1 id="h1Firstname">John</h1>
<span></div></span>
<script type="text/javascript">
var app = { firstname: "John", lastname: "Doe" };
inputFirstname.addEventListener("keyup",function(){
app.firstname = inputFirstname.value;
h1Firstname.textContent = app.firstname;
});
<span></script>
<p>
Change the name inside the input field,
and the model data will change automatically,
and therefore also the header will change its value.
</p>
</body>
</html></span>
</pre>
</td>
<td valign="top">
<pre>
<span><!DOCTYPE html>
<html></span>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<span><body></span>
<div ng-app="myApp" ng-controller="myCtrl">
Name: <input ng-model="firstname">
<h1>{{firstname}}</h1>
<span></div></span>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.firstname = "John";
$scope.lastname = "Doe";
});
<span></script>
<p>
Change the name inside the input field,
and the model data will change automatically,
and therefore also the header will change its value.
</p>
</body>
</html></span>
</pre>
</td>
</tr>
</table>
</body>
</html>