This time I will show you how to use the API of AngularJS, and what are the precautions for using the API of AngularJS. The following is a practical case, let's take a look.
Basicsbootstrap() Manually start AngularJSangular.element() Wraps a part of the DOM element or is HTML
String, treat it as a jQuery element. angular.module() Create, register or retrieve AngularJS module
angular.toJson() Sequence Convert JSON string
angular.isDate() If the reference is a date, return true
angular.isDefined () If the reference is defined, return true
angular.isElement() If the reference is a DOM element, return true
angular.isFunction() If the reference is a function, return true
angular.isNumber() If the reference Returns true if the reference is a number
angular.isObject() Returns true if the reference is an object
angular.isString() Returns true if the reference is a string
angular.isUndefined() Returns if the reference is undefined true
angular.equals() Returns true if the two objects are equal
angular.uppercase() Convert the character Convert string to uppercase
angular.copy() Deep copy of array or object
angular.forEach() Iteration function of object or array
When you need to copy an array or object, if you directly use $scope.user = $scope.master, it will cause linkage between the two parties, so you should use $scope.user = angular.copy($scope.master)
Use You need to pay attention to the following points when doing so:
Object copy To destination
If the source is null or undefined, the source will be returned directlyIf the source is the destination, an error will be reported. angular.forEach() Iteration of objects or arraysLoop for objectsvar values = {name: 'misko', gender: 'male'};var log = []; angular.forEach(values, function(value, key) { this.push(key + ': ' + value); }, log);
var objs =[{a:1},{a:2}];angular.forEach(objs, function(data,index,array) {//data等价于array[index]console.log(data.a+'='+array[index].a);});
Tips for using max-width and min-width
How to solve the problem of incomplete display of android textinput
The above is the detailed content of How to use AngularJS API. For more information, please follow other related articles on the PHP Chinese website!