转自:https://www.cnblogs.com/best/tag/Angular/
3.1、数据转换
示例:
默认情况JavaScript中对象是传引用的:
var tom={name:"tom",age:18,height:198}; var tomClone=tom; tomClone.name="superTom"; console.log(tom); console.log(tomClone);
结果:
修改后的示例:
var tom={name:"tom",age:18,height:198}; var tomClone=tom; var tome={} angular.copy(tom,tome); tomClone.name="superTom"; console.log(tom); console.log(tomClone); console.log(tome);
修改后的结果: