angular copy深度拷贝
来源:互联网 发布:plsql导入sql文件命令 编辑:程序博客网 时间:2024/05/21 11:06
angular提供了一个可以复制对象的api——copy(source,destination),它会对source对象执行深拷贝。
angular的操作实质是对dom的model进行操作,几乎所有的渲染都应放在model层。
<html ng-app="myApp"> <head> <meta charset='utf-8'> <script src="./angular.min.js"></script> </head> <div ng-controller="Controller"> <form> Name: <input type="text" ng-model="user.name" /><br /> E-mail: <input type="email" ng-model="user.email" /><br /> Gender: <input type="radio" ng-model="user.gender" value="male" />male <input type="radio" ng-model="user.gender" value="female" />female<br /> <button ng-click="reset()">RESET</button> <button ng-click="update(user)">SAVE</button> </form> <pre>form = {{user | json}}</pre> <pre>master = {{master | json}}</pre> </div> <script> var app = angular.module('myApp', []); app.controller('Controller', ['$scope', function($scope) { $scope.master= {}; $scope.update = function(user) { // Example with 1 argument $scope.master= angular.copy(user); }; $scope.reset = function() { // Example with 2 arguments angular.copy({}, $scope.user);//重置数据的层面放在此处,此处将一个空对象{}深拷贝到user中,可以根据需求放入原来的模型。 }; $scope.reset(); }]); </script> </html>
阅读全文
0 0
- angular copy深度拷贝
- angular.copy() 深拷贝
- C#深度拷贝(Deep Copy)
- 日常总结 之 angular copy 深拷贝
- copy class in flex(深度拷贝)
- Lua实现深度拷贝(Deep Copy)
- 5.7 copy--简单拷贝和深度拷贝对象
- angular.copy
- angular.copy()
- angular.copy
- Deep NSArray Mutable Copy Category behaviour (nsarray 深度拷贝)
- ArrayList的深度copy和浅度拷贝
- Copy List with Random Pointer 深度拷贝,浅度拷贝,Lazy拷贝解析
- 拷贝(copy)
- angular.copy方法
- angular.copy()功能学习
- 深度拷贝
- 附有随机结点指针的链表的深度拷贝 Copy List with Random Pointer
- 第24章 定义数据库性能
- 互联网行业的一天——摔!这和说好的不一样
- 华丽的HTML5图表 可展示实时数据
- SQL 语句大全
- 【dp】CodeForces
- angular copy深度拷贝
- httpclient 的 doPost请求中文乱码问题
- jekins发布时报time stamp xxx is xxx s in the future的问题解决办法
- Java集合实例解析
- hdu 1796 容斥定理
- 网络数据存到本地,无网络时取出本地数据
- STL之二分查找(binary_search(),lower_bound(),upper_bound() )
- HDU 1087 Super Jumping! Jumping! Jumping! (最长上升子序列求和)【最长序列求和类模板】
- Java与JSON(二)之使用