AngularJS的添加和区间的判断(过滤器)
来源:互联网 发布:大数据4v 编辑:程序博客网 时间:2024/06/06 04:57
molikaoshi.html
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <script src="../angular-1.5.5/angular.js"></script> <script src="molikaoshi.js"></script></head><body ng-app="myapp" ng-controller="myCtrl"><h1>添加新的球员</h1><p>姓名:<input type="text" ng-model="xm"/></p><p>位置:<input type="text" ng-model="wz"/></p><p>年龄:<input type="text" ng-model="nl"/></p><p>球队:<input type="text" ng-model="qy"/></p><button ng-click="add()">添加新的球员</button><h3>用户信息表</h3><input type="text" placeholder="用户名查询" ng-model="mh"/> 年龄:<select ng-model="ss"> <option>--请选择--</option> <option>18-25</option> <option>26-35</option></select><table> <tr> <th>球员</th> <th>姓名</th> <th>位置</th> <th>年龄</th> <th>球队</th> <th>得票数</th> <th>操作</th> </tr> <tr ng-repeat="item in users|filter:mh|filter:agefilter"> <td><img src="{{item.url}}"/></td> <td>{{item.name}}</td> <td>{{item.wz}}</td> <td>{{item.age}}</td> <td>{{item.qd}}</td> <td>{{item.page}}</td> <td><button ng-click="tp($index)">投票</button></td> </tr></table></body></html>molikaoshi.js
var myapp=angular.module("myapp",[]);myapp.controller("myCtrl",function ($scope) { $scope.users=[ {'url':"images/1.png", 'name':"Westbrook", 'wz':"得分后卫(SG)", "age":24, "qd":"雷霆", "page":1900}, {'url':"images/2.png", 'name':"James",'wz':"大前锋(PF)", "age":23, "qd":"骑士", "page":1900}, {'url':"images/3.png", 'name':"Curry",'wz':"得分后卫(SG)", "age":30, "qd":"勇士", "page":1800}, {'url':"images/4.png", 'name':"Harden", 'wz':"小前锋(SG)", "age":13, "qd":"火箭", "page":1800}, {'url':"images/5.png", 'name':"Durant", 'wz':"得分后卫(SG)", "age":35, "qd":"勇士", "page":1712} ]; $scope.xm=""; $scope.wz=""; $scope.qy=""; $scope.nl=""; //添加的点击事件 $scope.add=function () { //往数组中添加输入的内容 $scope.users.unshift({'name':$scope.xm, 'wz': $scope.wz, "age":$scope.nl, "qd":$scope.qy, "page":1712,'url':"images/7.png"}) } //投票的功能 $scope.tp=function (index) { $scope.users[index].page++; } //模糊查询 $scope.mh=""; //按年龄区域查询 $scope.ss="--请选择--"; $scope.agefilter=function (item) { if($scope.ss!="--请选择--"){ $scope.st=$scope.ss; var arr=$scope.st.split("-"); var min=arr[0]; var max=arr[1]; if(item.age<min||item.age>max){ return false; }else{ return true; } }else { return true; } }})
阅读全文
0 0
- AngularJS的添加和区间的判断(过滤器)
- angularjs的添加和非空判断
- angularJS过滤器和自定义的过滤器
- AngularJS的添加信息判断+路由
- angularJS的过滤器详解
- angularjs的过滤器
- AngularJS 霸道的过滤器
- angularjs过滤器的学习
- 常用的AngularJS过滤器
- angularJS的过滤器
- AngularJs 常用的过滤器
- AngularJs的过滤器
- AngularJS的过滤器总结
- angularjs的使用:过滤器(5)
- AngularJS的内置过滤器总结
- Angularjs 的过滤器使用小结
- 区间重叠的判断
- AngularJS控制器和过滤器学习(三)
- 编程输出如下图像。
- PingCAP 分布式数据库TiDB介绍
- codevs 1204寻找子串位置(kmp算法)
- RMQ问题——ST算法
- 内存溢出与内存泄漏
- AngularJS的添加和区间的判断(过滤器)
- L7 环境变量PATH,cp和mv命令,文档查看cat more less head tail
- 洛谷P2678 跳石头(NOIp2015)
- 编译与链接详解
- Calculator
- 再来谈谈vue.js
- PullToRefresh ScrollView的Listview和轮播图组合Mylistview适配
- MySQL之主键、外键、索引
- LightOJ-1020-A Childhood Game