angular.copy()
<!DOCTYPE html>
<html> <head>
<meta charset="UTF-8">
<title>angular.copy</title>
</head> <body ng-app="copyExample">
<h1>angular.copy</h1>
<p>
<span>描述:</span><br />
<span>复制一个对象或者数组</span>
</p>
<p>
<span>使用方法:</span><br />
<span>angular.copy(source, [destination])</span>
</p>
<p>
<span>参数:</span><br />
<span>source: 被copy的对象,可以使用任意类型,包括null和undefined</span><br />
<span>destination(optional):Object || array,copy去的目的地可以省略,如果不省略,其必须和source是同类</span><br />
</p>
<p>
<span>返回值:</span><br />
<span>返回这个应用程序的新创建的injector(注入)对象</span>
</p>
<hr />
<div ng-controller="exampleController">
<form novalidate class="siple_form">
姓名:<input type="text" ng-model="user.name"/><br />
邮箱:<input type="email" ng-model="user.email"/>(输入email格式)<br />
性别:<input type="radio" ng-model="user.gender" value="boy"/>男
<input type="radio" ng-model="user.gender" value="girl"/>女<br />
<button ng-click="reset()">reset</button>
<button ng-click="save(user)">save</button>
</form>
<pre>form = {{user | json}}</pre>
<pre>master = {{master | json}}</pre>
</div>
</body>
<script src="../../js/angular.1.3.0.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
angular.module('copyExample', []).controller('exampleController', ['$scope', function($scope){
$scope.master = {};
$scope.save = function(user){
//console.log('保存')
$scope.master = angular.copy(user)
};
$scope.reset = function(){
//console.log('重置')
angular.copy($scope.master, $scope.user)
}
$scope.reset();
}])
</script> </html>
angular.copy()的更多相关文章
- angular.extend()和 angular.copy()的区别
1.angular.copy angular.copy(source, [destination]); // source: copy的对象. 可以使任意类型, 包括null和undefined. ...
- AngularJs angular.bind、angular.bootstrap、angular.copy
angular.bind 返回一个调用self的函数fn(self代表fn里的this).可以给fn提供参数args(*).这个功能也被称为局部操作,以区别功能. 格式:angular.bind(se ...
- angular.js 的angular.copy 、 angular.extend 、 angular.merge
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- Angular - - angular.bind、angular.bootstrap、angular.copy
angular.bind 返回一个调用self的函数fn(self代表fn里的this).可以给fn提供参数args(*).这个功能也被称为局部操作,以区别功能. 格式:angular.bind(se ...
- angular.copy(source, destination)
angular.copy(source, destination)只有1个参数,返回source的深拷贝有2个参数source的深拷贝复制给destination
- angular : copy vs extend
While using AngularJS, we come across some situation in which we need to copy one object to another ...
- AngularJS方法 —— angular.copy
描述: 复制一个对象或者一个数组(好吧,万物皆对象,数组也是一个对象). 如果省略了destination,一个新的对象或数组将会被创建出来: 如果提供了destination,则source对象中的 ...
- angular JS中 ‘=’与angular.copy的区别
先来看代码: <b>{{test1}}</b> <input type="text" ng-model="test2" title ...
- angular.extend vs angular.copy
1.angular.copy angular.copy(source, [destination]); // source: copy的对象. 可以使任意类型, 包括null和undefined. ...
随机推荐
- BETA准备
过去存在的问题 文档问题 未能事先做好设计文档,且小程序与后端数据库接口存在问题 界面问题 原型图设计花的时间较少,小程序设计界面仍相对粗糙,前端成员css元素应用经验不足 小程序界面之间对接存在问题 ...
- python对象、引用
1.python对象 python中 所有的python对象都有3个特征: 身份,类型和值 身份: 每个对象有一个唯一的身份标识自己,这个值可以被认为是该对象内存地址.id()查看. 类型 type( ...
- 浏览器iscroll
::-webkit-scrollbar{width:4px;height:4px;background:transparent}::-webkit-scrollbar-track{background ...
- UOJ#207. 共价大爷游长沙 LCT
原文链接https://www.cnblogs.com/zhouzhendong/p/UOJ207.html 题解 第一次听说 LCT 还可以维护子树信息. 首先对于每一条路径 rand 一个值,分别 ...
- 2018牛客网暑假ACM多校训练赛(第四场)D Another Distinct Values 构造
原文链接https://www.cnblogs.com/zhouzhendong/p/NowCoder-2018-Summer-Round4-D.html 题目传送门 - https://www.no ...
- 转载:搭建完整的arm-linux-gcc等交叉编译环境(感谢CSDN博主的分享)
安装环境 Linux版本:Ubuntu 12.04 内核版本:Linux 3.5.0 交叉编译器版本:arm-linux-gcc-4.4.3 这个版本的交叉编译器 安装前的絮叨 首先简单介绍 ...
- 爬虫之xpath用法
导包用: from lxml import etree
- ubuntu中git
1.在ubuntu中安装git $ sudo apt-get install git git-core 2.配置本机的git $ git config --global user.name " ...
- hdu-2043解题报告
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2043 题意解析:目的是判断一串密码是否安全,条件是满足1.大写字母:A,B,C...Z; 2.小写 ...
- Java使用序列化的私有方法巧妙解决部分属性持久化问题
部分属性持久化问题看似很简单,只要把不需要的持久化的属性加上瞬态关键字(transient关键字)即可,没错,这也是一种解决方案,但在有的时候行不通,例如在一个计税系统和人力系统对接的时候,计税系统需 ...