<!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()的更多相关文章

  1. angular.extend()和 angular.copy()的区别

    1.angular.copy angular.copy(source, [destination]);  // source: copy的对象. 可以使任意类型, 包括null和undefined. ...

  2. AngularJs angular.bind、angular.bootstrap、angular.copy

    angular.bind 返回一个调用self的函数fn(self代表fn里的this).可以给fn提供参数args(*).这个功能也被称为局部操作,以区别功能. 格式:angular.bind(se ...

  3. angular.js 的angular.copy 、 angular.extend 、 angular.merge

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  4. Angular - - angular.bind、angular.bootstrap、angular.copy

    angular.bind 返回一个调用self的函数fn(self代表fn里的this).可以给fn提供参数args(*).这个功能也被称为局部操作,以区别功能. 格式:angular.bind(se ...

  5. angular.copy(source, destination)

    angular.copy(source, destination)只有1个参数,返回source的深拷贝有2个参数source的深拷贝复制给destination

  6. angular : copy vs extend

    While using AngularJS, we come across some situation in which we need to copy one object to another ...

  7. AngularJS方法 —— angular.copy

    描述: 复制一个对象或者一个数组(好吧,万物皆对象,数组也是一个对象). 如果省略了destination,一个新的对象或数组将会被创建出来: 如果提供了destination,则source对象中的 ...

  8. angular JS中 ‘=’与angular.copy的区别

    先来看代码: <b>{{test1}}</b> <input type="text" ng-model="test2" title ...

  9. angular.extend vs angular.copy

    1.angular.copy angular.copy(source, [destination]);  // source: copy的对象. 可以使任意类型, 包括null和undefined. ...

随机推荐

  1. OAuth2:客户端证书授权(Client Credentials)类型的开放授权

    适应范围 认证服务器不提供像用户数据这样的重要资源,仅仅是有限的只读资源或者一些开放的API.例如使用了第三方的静态文件服务,如Google Storage或Amazon S3.这样,你的应用需要通过 ...

  2. 【Android】Bitmap加载图片错误 java.lang.OutOfMemoryError: bitmap size exceeds VM budget

    今天测试程序的时候出现下面的错误日志信息,程序当场挂掉 07-09 14:11:25.434: W/System.err(4890): java.lang.OutOfMemoryError: bitm ...

  3. TypeScript学习笔记 (一)基础特性

    一. 字符串新特性 1. 多行字符串 var str = ``; 2. 字符串模板 var world = "world"; var str = `hello ${world}`; ...

  4. Python_str 的内部功能介绍

    float: x.as_integer_ratio():把浮点型转换成分数最简比 x.hex():返回当前值的十六进制表示 x.fromhex():将十六进制字符串转换为浮点型 float与long的 ...

  5. Nginx动静分离架构&&HA-LB集群整合

    Nginx动静分离简单来说就将动态与静态资源分开,不能理解成只是单纯的把动态页面和静态页面物理分离,严格意义上说应该是动态请求跟静态请求分开,可以理解成使用Nginx处理静态页面,Tomcat,Res ...

  6. liunx命令简介

    图形界面和命令行要达到的目的是一样的,都是让用户控制计算机.然而,真正能够控制计算机硬件(CPU.内存.显示器等)的只有操作系统内核(Kernel),图形界面和命令行只是架设在用户和内核之间的一座桥梁 ...

  7. Centos7 安装PhantomJS

    1.下载地址:http://phantomjs.org/download.html 2.文件名:phantomjs-2.1.1-linux-x86_64.tar.bz2   # 下载好后进行解压(由于 ...

  8. 001.Kubernetes简介

    一 Kubernetes概述 Kubernetes是一个全新的基于容器技术的分布式架构领先方案.Kubernetes(k8s)是Google开源的容器集群管理系统(谷歌内部:Borg).在Docker ...

  9. CDN拾遗

    作为前端er,辛辛苦苦搬完砖,好不容易上线之后,正准备告一声万事大吉,回家吃鸡.忽然qa/pm/老板问,为什么我这里还是没有更新?只能是弱弱的回一声,清个缓存看看?或者还有那么一天,发现大部分区域都是 ...

  10. Cursor for loop in Oracle

    declare l_sql ); -- variable that contains a query l_c sys_refcursor; -- cursor variable(weak cursor ...