<!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. Maven+SpringMVC+SpringFox+Swagger整合示例

    查考链接:https://my.oschina.net/wangmengjun/blog/907679 coding地址:https://git.coding.net/conding_hjy/Spri ...

  2. [转]JAVA实现SFTP实例

    http://www.cnblogs.com/chen1987lei/archive/2010/11/26/1888384.html 最近写的一个JAVA实现SFTP的实例: /** Created ...

  3. redcontrol for SL 中文化及样式选择

    app.xaml.cs public partial class App: Application    {        public App()        {            //指定t ...

  4. mysql-数据库管理安装

    第一节 数据库管理系统 相关网址:www.db-engines.com mysql站点:www.mysql.com mariadb.org   mariadb官方站点 数据库分类: 关系型数据库: o ...

  5. sql 表值函数-将一个传入的字符串用2中分隔符拆分成临时表

    USE [tms]GO/****** Object: UserDefinedFunction [dbo].[fn_StrToTable_Double] Script Date: 2017/4/26 9 ...

  6. 040 Http与RPC

    一直在说,但是没有系统的文档理解过. 1.本质 目前有很多Java的RPC框架,有基于Json的,有基于XML,也有基于二进制对象的. 他们最本质的区别,就是RPC主要是基于TCP/IP协议的,而HT ...

  7. jquery模拟form表单提交并新打开页面

    /** * form表单提交本页面打开 * @param url * @param params */ function postCurrent(url,params){ var form = $(& ...

  8. python 精确计算与向上取整 decimal math.ceil

    1. 精确计算 python的float型不精确,需要导入decimal包,以下是不精确举例: 导入decimal包后: 2. 向上取整 一般的取整数(向下取整): 向上取整的方法:

  9. INSERT 中ON DUPLICATE KEY UPDATE的使用

    如果您指定了ON DUPLICATE KEY UPDATE,并且插入行后会导致在一个UNIQUE索引或PRIMARY KEY中出现重复值,则执行旧行UPDATE.例如,如果列a被定义为UNIQUE,并 ...

  10. 解决UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position

    最近用Python写了些爬虫,在爬取一个gb2312的页面时,抛出异常: UnicodeEncodeError: 'ascii' codec can't encode characters in po ...