json对象集合(添、删、改)
来源:互联网 发布:笛佛软件面试 编辑:程序博客网 时间:2024/06/16 09:03
<!doctype html><html ng-app><head> <title></title> <script type="text/javascript" src="angular.min.js"></script> <script type="text/javascript"> function my_controller($scope) { $scope.students = [ { id: 1, name: '张一' }, { id: 2, name: '李二' } ]; $scope.add_student = function () {//添加 var student = { id: 3, name: '余三' }; $scope.students.push(student); } $scope.delete_student = function (_id) {//删除 var index = $scope.get_index(_id); $scope.students.splice(index, 1); } $scope.update_student = function (_id) {//修改 var index = $scope.get_index(_id); var student = { id: _id, name: '马二' }; $scope.students.splice(index, 1, student); } $scope.get_index = function (_id) {//获取对象在数组中index if ($scope.students.length > 0) { for (var i = 0; i < $scope.students.length; i++) { if ($scope.students[i].id == _id) { return i; } } } } } </script></head><body ng-controller="my_controller"> <input type="button" value="add" ng-click="add_student();" /> <input type="button" value="delete" ng-click="delete_student(1);" /> <input type="button" value="update" ng-click="update_student(2);" /> <table> <tr ng-repeat="item in students"> <td>{{item.id}}</td> <td>{{item.name}}</td> </tr> </table></body></html>
0 0
- json对象集合(添、删、改)
- json的增删改(json操作对象)
- json对象(json-lib)转换成list-map集合
- javascript json对象操作(基本增删改查)
- Json 增 删 改
- Map集合转换JSON对象
- json传对象或集合
- json集合字符串转对象
- Json传递对象集合 JSON.net使用
- JSON--List集合转换成JSON对象
- JSON--List集合转换成JSON对象
- JSON--List集合转换成JSON对象
- JSON--List集合转换成JSON对象
- JSON--List集合转换成JSON对象
- 对json对象的增删改查
- 关于json对象的增删改查
- JSON转换类(二)--List转换成Json、对象集合转换Json等
- handlebars获取json数据(集合对象中嵌套集合对象)each嵌套使用
- java_数组声明、创建、初始化,对象数组
- 1、Spring之HelloWorld
- Redis源码学习3-基本数据结构之双向链表
- C++学习笔记精华
- Neural Netowrk : BackPropagation
- json对象集合(添、删、改)
- 第五篇--自定义View
- JAVA基础常识
- ubuntu14.04LTS安装JAVA8和eclipse4.4
- 线程锁的概念函数EnterCriticalSection和LeaveCriticalSection的用法
- Redis源码学习1——基本数据结构sds
- 最适合加密敏感数据的算法。每次传输的数据都不一样,即使黑客都头疼额。使用了md5加密。
- 背包问题详解(转)
- 2、Spring4之Bean的两种配置方式