@ The beast's NG API Learning--Angular.copy
Angular.copy
Create a deep copy of the object or number.
Format: angular.copy (source, [destination]);
Source: The object being copied
Destination: Received Object [Note: The parameter type is an object or an array]
Using code:
var obja, OBJD = []; obja:undefined objd:[]
var objb = {text: "Hello World"};
var OBJC = {text: "Hai", Value: "Test"};
Obja = Angular.copy (OBJB); obja:{text: "Hello World"} objb:{text: "Hello World"}
Angular.copy (OBJC, OBJD);//objc:{text: "Hai", Value: "Test"} objd:[text: "Hai", Value: "Test"]
@ Beast to angular API one after the translation of their own, and then write the code to run successfully, just recorded ... @ the Beast knows there is a similar translation on the Internet, but @ the Beast has the Pride of the Beast. Do not copy the results of others, must be their own translation, write their own code, see the source (part, not all ...) I've seen jquery before, all of them are tired, so I can get a deeper understanding of these methods ...
OK, tear down angular.copy, or according to the above code to explain ...
First of all, Obja = Angular.copy (OBJB), the meaning of the OBJB copy, and then the contents of the copy depth assigned to a, when a from the original undefined into the object{text: "Hello World"}. However, @ the Beast put Obja and objb in comparison with = =, found that the return is false, I also put obja = OBJB, and then to the ratio of = =, then return is true. This pit @ The beast does not know how to fill it at the moment (I'm afraid I'm shallow ...) Is there a great God willing to answer? ), because TypeOf under Obja and OBJB, are object, and the properties/values are the same ....
Then say Angular.copy (OBJC,OBJD), this is OBJC copy to OBJD, and then I direct Var objd, found that after the execution of this sentence objd or undefined, and then the beast went to see the API, Discovery format: The Receiving object in Angular.copy (source, [destination]) is the one with [], and then the API website gives the explanation, this parameter is an object or an array, OK, then the @ Beast will try it with objects or arrays ... It sure did.
Well, Angular.copy's explanation is over here. The beast's understanding of angular.copy
Hey! @ Beast, your NG API is out--angular.copy