English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

MVC WeChat Webpage Authorization to Obtain User OpenId

Angular provides an API for copying objects - copy(source, destination), which will perform a deep copy of the source object.

The following points should be noted when using it:

  1. If only one parameter is provided (no specified copy object), a copy object will be returned
  2. If destination is specified, the object will be deeply copied to destination
  3. If source is null or undefined, source will be returned directly
  4. If source is the same as destination, an error will be reported.

Let's see some examples below:

<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <script src="http://apps.bdimg.com/libs/angular.js/1.2.16/angular.min.js"></script>
</head>
<body ng-app="copyExample">
  <div ng-controller="ExampleController">
    <form novalidate class="simple-form">
      Name: <input type="text" ng-model="user.name" /><br />
      E-mail: <input type="email" ng-model="user.email" /><br />
      Gender: 
      <input type="radio" ng-model="user.gender" value="male" />
      male
      <input type="radio" ng-model="user.gender" value="female" />
      female
      <br />
      <button ng-click="reset()">RESET</button>
      <button ng-click="update(user)">SAVE</button>
    </form>
    <pre>form = {{user | json}}</pre>
    <pre>master = {{master | json}}<</pre>/pre>
  </div>
  <script>
  angular.module('copyExample', [])
  .controller('ExampleController', ['$scope', function($scope) {
    $scope.master = {};
    var test1;
    console.log(angular.copy(test1));//undefined
    var test3=null;
    console.log(angular.copy(test2));//undefined
    var test2 = "a";
    // console.log(angular.copy(test2,test2));//error!!
    $scope.update = function(user) {
      // Example with 1 argument
      $scope.master = angular.copy(user);
    });
    $scope.reset = function() {
      // Example with 2 arguments
      angular.copy($scope.master, $scope.user);
      console.log($scope.master);
      console.log($scope.user);
    });
    $scope.reset();
  });
  </script>
</body>
</html>

This is the summary of the AngularJS API's copy deep copy, and we will continue to supplement relevant information. Thank you all for your support of this site!

Declaration: The content of this article is from the Internet, and the copyright belongs to the original author. The content is contributed and uploaded by Internet users spontaneously. This website does not own the copyright, has not been edited by humans, and does not assume any relevant legal liability. If you find any content suspected of copyright infringement, please send an email to: notice#oldtoolbag.com (Please replace # with @ when sending an email to report violations, and provide relevant evidence. Once verified, this site will immediately delete the infringing content.)

Elasticsearch Tutorial