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. ...
随机推荐
- SPOJ 1812 LCS2
题解: 和上一题差不多 每个点记录前面的到这个点的最大值 初值赋为len[i] 然后注意要用子节点更新父节点 代码: #include <bits/stdc++.h> #define ll ...
- mysql分组(五)
MySQL GROUP BY 语句 GROUP BY 语句根据一个或多个列对结果集进行分组. 在分组的列上我们可以使用 COUNT, SUM, AVG,等函数. GROUP BY 语法 SELECT ...
- mariadb-半同步复制
半同步复制: 使用插件 对于从节点,有一部分为同步复制,当主节点复制完从节点后才向客户返回ok,同步超时后自动降级为异步 有一部分为异步复制 这样为了与主节点冗余 基于主从的模式上搭建 半同步复制: ...
- Codeforces 305E Playing with String 博弈
我们可以把每段连续可以选的字符看成一个游戏, 那么sg[ i ]表示连续 i 个字符可选的sg值. 然后找找第一个就好啦. #include<bits/stdc++.h> #define ...
- Python 事件驱动与异步IO
一.事件驱动编程是一种编程范式,这里程序的执行流由外部事件来决定.它的特点是包含一个事件循环,当外部事件发生时使用回调机制来出发相应的处理.另外两种常见的编程范式是(单线程)同步以及多线程编程. 1. ...
- jmeter访问mysql数据库
jdbc:mysql://localhost:3306/jy?allowMultiQueries=true 如果想同时执行多条语句
- SSM知识点与整合之Spring知识点(pom.xml需要依赖的jar或者plugin)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...
- 学习Spring必须了解的基础知识——回调机制
上面这张图如果能看得懂就能理解什么是回调机制: A对象在调用a()方法时会调用B对象的b()方法,b()方法必须能调用A对象的callback()方法. 谁白了:a()方法有B对象b()方法的引用,b ...
- JavaSE | 接口| 枚举| 注释| 异常
包: 1.包的作用:(1)避免类的同名(区分类):类的全名称:包.类名 回忆:java.util.Scannerjava.util.Arraysjava.lang.Stringj(2)可以限定某些类或 ...
- Python 解决 :NameError: name 'reload' is not defined 问题
对于 Python 2.X: import sys reload(sys) sys.setdefaultencoding("utf-8") 1 2 3 对于 <= Pytho ...