• 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>
  • 相关阅读:
    C/C++指针精髓转载
    彻底搞定c指针系列转载
    vc根据域名获取IP地址 gethostbyname()函数
    try catch finally的执行顺序
    vc2008中mfc字符串转换待续
    C++字符串完全指引(二)转载
    vc随机字符串
    C++字符串完全指引转载
    编写c++程序的优良习惯
    ReportViewer一些技巧
  • 原文地址:https://www.cnblogs.com/tanxiang6690/p/9764647.html
Copyright © 2020-2023  润新知