AngularJS(DIY)
来源:互联网 发布:未来城网络黄金ios下载 编辑:程序博客网 时间:2024/05/24 01:49
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <script src="angular1.4.6.min.js"></script> <script src="jquery-3.2.1.js"></script> <script src="https://apps.bdimg.com/libs/angular-route/1.3.13/angular-route.js"></script> <style> .div.top { height: 80px; width: 800px; } .div_center{ margin-top: 20px; height:auto; width: 800px; } .div_content{ width: 800px; height: 500px; } </style></head><body ng-app="myApp" ng-controller="myController"> <script> //路由操作 var myApp = angular.module("myApp", ['ngRoute']); myApp.config(function ($routeProvider) { $routeProvider.when("/add", { templateUrl: "add.html", controller: "addCtrl" }).when("/update", { templateUrl: "update.html", controller: "updateCtrl" }) }); <!-- 初始化数据操作--> myApp.controller("myController", function ($scope) { $scope.data = [ {id: 1, name: "张三", pass: 111, age: 20, sex: "男"}, {id: 2, name: "李四", pass: 222, age: 21, sex: "男"}, {id: 3, name: "王五", pass: 333, age: 22, sex: "男"}, ] //删除操作 $scope.del=function () { $scope.data=[]; } }); <!-- 添加操作--> myApp.controller("addCtrl",function ($scope) { $scope.tijiao=function () { var newUser={ id:$scope.id, name:$scope.name, pass:$scope.pass, age:$scope.age, sex:$scope.sex }; $scope.data.push(newUser) } }); <!-- 修改操作--> myApp.controller("updateCtrl",function ($scope) { var ii=0; $scope.tijiao=function () { $scope.data[ii].pass=$scope.newpass; } }); </script> <center> <div class="div_top"> 用户名:<input type="text" ng-model="searchname" placeholder="用户名查询"> 年龄:<input type="text" ng-model="searchage" placeholder="年龄范围查询"> 性别:<select ng-model="sex"> <option></option> <option>男</option> <option>女</option> </select> <button ng-click="del()">全部删除</button> </div> <div class="div_center"> <table border="1px solid" cellpadding="20px"> <thead> <th> id </th> <th> 用户名 </th> <th> 密码 </th> <th> 年龄 </th> <th> 性别 </th> <th> 操作 </th> </thead> <tbody> <tr ng-repeat="item in data | filter:searchname | filter:searchage | filter:sex"> <td>{{item.id}}</td> <td>{{item.name}}</td> <td>{{item.pass}}</td> <td>{{item.age}}</td> <td>{{item.sex}}</td> <td> <button ng-click="up($index)"><a href="#update">修改密码</a></button> </td> </tr> </tbody> </table> </div> <button style="width: 100px;margin-top: 10px"><a href="#add">添加用户</a></button> <div ng-view="" class="div_content" > </div> </center></body></html>
//add页面
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <style> .div_add{ margin-top: 10px; line-height: 30px; } </style></head><body><ceter> <div class="div_add"> id:<input type="text" ng-model="id"><br> 用户名:<input type="text" ng-model="name"><br> 密码:<input type="text" ng-model="pass"><br> 年龄:<input type="text" ng-model="age"><br> 性别:<input type="text" ng-model="sex"><br> <button ng-click="tijiao()">提交</button> </div></ceter></body></html>
阅读全文
1 0
- AngularJS(DIY)
- DIY
- DIY
- DIY
- IIS 5.0 DIY (转)
- DIY-作业(更新中)
- DIY点读笔(O-pen)
- 代码统计工具(DIY)
- DIY脑电图(心电图)电路
- diy数据库系列(引言)
- diy数据库(一)--概况
- diy数据库(十)--索引
- 游戏修改器DIY(一)
- 打造计数器DIY三步曲(中)
- Acmer Codeblocks DIY(推荐使用codeblocks)
- poj 1416 组合数(DIY碎纸机)
- NAS DIY(1)freebsd配置
- NAS DIY(2)配件清单
- 批量去除Word的向下小箭头
- 显示全部
- Python3爬虫之六网页的初步分析【抓取豆瓣最新电影影评并用词云显示】
- 自学redis简单命令
- 解决git无法clone提示443以及配置git代理方法
- AngularJS(DIY)
- MSM8998(高通835处理器)外接指纹识别传感器linux驱动详解
- opencv-鼠标操作
- 转importnew阿里面试回来,想和 Java 程序员谈一谈(职业学习规划参考)
- vi和vim的区别
- 使用git遇到的错误
- 论文投稿与点评
- 一分钟开启Tomcat https支持
- 算法导论10.2-5 使用单向循环链表实现字典操作 INSERT、DELETE 和 SEARCH