<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript" src="js/angular.js"></script>
<script type="text/javascript">
angular.module("myApp",[]).controller("myCtrl",function($scope){
$scope.list=[];
$scope.add = function(){
var i = {
name:$scope.name,
age:$scope.age,
sex:$scope.sex,
};
$scope.list.push(i);
};
});
</script>
<body>
<center>
<div ng-app="myApp" ng-controller="myCtrl">
<table border="1px soild #000">
<thead>
<th>姓名</th>
<th>密码</th>
<th>年龄</th>
</thead>
<tr ng-repeat=" x in list">
<td>{{x.name}}</td>
<td>{{x.age}}</td>
<td>{{x.sex}}</td>
</tr>
</table>
姓名:<input type="text" ng-model="name"><br/><br />
密码:<input type="text" ng-model="age"><br/><br />
年龄:<input type="text" ng-model="sex" /><br /><br />
<button ng-click="add()">添加</button>
</div>
</center>
</body>
</html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript" src="js/angular.js"></script>
<script type="text/javascript">
angular.module("myApp",[]).controller("myCtrl",function($scope){
$scope.list=[];
$scope.add = function(){
var i = {
name:$scope.name,
age:$scope.age,
sex:$scope.sex,
};
$scope.list.push(i);
};
});
</script>
<body>
<center>
<div ng-app="myApp" ng-controller="myCtrl">
<table border="1px soild #000">
<thead>
<th>姓名</th>
<th>密码</th>
<th>年龄</th>
</thead>
<tr ng-repeat=" x in list">
<td>{{x.name}}</td>
<td>{{x.age}}</td>
<td>{{x.sex}}</td>
</tr>
</table>
姓名:<input type="text" ng-model="name"><br/><br />
密码:<input type="text" ng-model="age"><br/><br />
年龄:<input type="text" ng-model="sex" /><br /><br />
<button ng-click="add()">添加</button>
</div>
</center>
</body>
</html>
这篇博客展示了如何使用AngularJS创建一个简单的登录界面。通过HTML和JavaScript代码,实现了输入姓名、密码和年龄并将其添加到表格的功能。AngularJS的ng-model和ng-repeat指令用于双向数据绑定和动态显示数据。
1万+

被折叠的 条评论
为什么被折叠?



