1. AngularJS tool method, refer to AngularJS API HTTPS://DOCS.ANGULARJS.ORG/API official documentation
(1) Angular.isarray (value) determines whether it is an array, returning TRUE/FALSE
[HTML]View PlainCopy
- <div ng-controller="Firstcontroller">{{isarray}}</div>
[HTML]View PlainCopy
- $scope.arr=[1,2,3];
- $scope.isarray=angular.isarray ($scope. arr);
(2) Angular.isdate (value) determines whether it is a date type and returns True/false
(3) angular.iddefined (value) determines whether or not it is defined and returns True/false
(4) angular.iselement (node) determines if it is a DOM node and returns True/false
(5) Angular.isfunction (value) determines whether it is a function type and returns TRUE/FALSE
(6) Angular.isnumber (value) determines whether the number type, which includes nan,infinity and-infinity, returns True/false
(7) Angular.isobject (value) determines whether it is an object type, array is a OBJCT type, NULL is not an object type, and returns True/false
(8) Angular.isstring (value) determines whether it is a string type and returns True/false
(9) Angular.uppercase (value) converted to uppercase
[HTML]View PlainCopy
- <div ng-controller="Firstcontroller">{{name1}}</div>
[HTML]View PlainCopy
- $scope.name=' Zhangsan ';
- $scope.name1=angular.uppercase ($scope. Name);
(+) Angular.lowercase (value) converted to lowercase
(one) angular.equals (O1,O2) determines whether two strings are equal and returns True/false
[HTML]View PlainCopy
- <div ng-controller="Firstcontroller">{{eq}}</div>
[HTML]View PlainCopy
- $scope.a=' 111 ';
- $scope.b=' 111 ';
- $scope.eq=angular.equals ($scope. A, $scope. b);
Angular.extend (DST,SRC) inheritance relationship, as shown in the following code, b inherits the properties of a
[HTML]View PlainCopy
- $scope.a={name: ' Zhang San '};
- $Scope.b={age:10};
- $scope.c=angular.extend ($scope. B, $scope. a);
- Console.log ($scope. b);//{"Age": Ten, "Name": "Zhang San"}
Angular.fromjson (JSON) deserializes a JSON string into a JavaScript object
[HTML]View PlainCopy
- var json = ' {' name ': ' Hello ', ' age ': ' 20 '} ';
- Console.log (JSON);
- $scope.json=Angular.fromjson (JSON);
- Console.log ($scope. JSON);
Angular.tojson (Obj,pretty) format JSON string
[HTML]View PlainCopy
- var json = {"name": "Hello", "Age": "20"};
- Console.log (JSON);
- $scope.json=Angular.tojson (JSON);
- $scope.json=Angular.tojson (json,true);
- Console.log ($scope. JSON);
(15) angular. Copy(source, [destination]), as shown in the following code, copies a to B
[HTML]View PlainCopy
- $scope.a={name: ' Zhang San '};
- $Scope.b={age:10};
- $scope.c=angular.copy ($scope. A, $scope. b);
- Console.log ($scope. a);
- Console.log ($scope. b);
(16) angular. ForEach(obj, iterator, [context])
[HTML]View PlainCopy
- var json = {"name": "Hello" , "Age": "A", "sex": ' Male '};
-
- angular.foreach (JSON, function (Val,key) {
-
- // Console.log (val);
- console.log (key);
-
[HTML]View PlainCopy
- var json = {"name": "Hello" , "Age": "A", "sex": ' Male '};
-
- var RESULTS=[];&NBSP;&NBSP;
-
- angular.foreach (Json,function (val,key) {
- // Console.log (val);
- //console.log (key);
- this.push (key+ '---' +val);
- },results)
-
- console.log (results);
(17) angular. Bind(self, fn, args), binding object, as the context of the function
[HTML]View PlainCopy
- var self={name: ' Zhang San '};
- var f=Angular.bind (self,function (age) {
- $scope.info=this.name+ ' is ' +age;
- Console.log ($scope. info);
- });
- F (30);
- var f=Angular.bind (self,function (age) {
- $scope.info=this.name+ ' is ' +age;
- Console.log ($scope. info);
- },10);
- f ();
AngularJS tool methods and using jquery in AngularJS