1.angular.bind
var self = {name: ‘boy‘}; var f = angular.bind(self, function (age) { alert(this.name + ‘ is ‘ + age + ‘ !‘)}); f(12);
2、angular.bootstrap
var app = angular.module(‘demo‘, []) .controller(‘WelcomeController‘, function($scope) { $scope.greeting = ‘Welcome!‘; }); angular.bootstrap(document, [‘demo‘]);
3、angular.copy
使用angular.copy拷贝后会指向一个新地址
4、angular.element
angular.element(document.getElementById(‘ddd‘)).addClass(‘ccc‘)
5、angular.equal(pram1,pram2);
angular.equal("a","a");//true console.log(angular.equals(true,1)); //false 不能进行强转化 var a={a:111}; var b={a:111}; console.log(angular.equals(a, b)); //true
6、angular.forEach(Arr,fn,[context])
//对象遍历 var values = {name: ‘misko‘, gender: ‘male‘}; var log = []; angular.forEach(values, function(value, key) { log.push(key + ‘: ‘ + value); }); console.log(log); //["name: misko", "gender: male"]
var values = {name: ‘misko‘, gender: ‘male‘};
var log = []; angular.forEach(values, function(value, key) { this.push(key + ‘: ‘ + value); },log); //["name: misko", "gender: male"]
//数组遍历 var values = [1,2,3]; var log = []; angular.forEach(values, function(value, key) { log.push(key + ‘: ‘ + value); }); console.log(log);
7、angular.fromJson
var json = ‘{"name":"liSi", "password":"321"}‘; var jsonArr = ‘[{"name":"zhangSan", "password":"123"},{"name":"liSi", "password":"321"}]‘; var obj = angular.fromJson(json); console.log(obj); var objArr = angular.fromJson(jsonArr); console.log(objArr);
8、angular.identity
function getResult(fn, input) { return (fn || angular.identity)(input); }; getResult(function(n) { return n * 2; }, 21); // returns 42 getResult(null, 21); // returns 21 getResult(undefined, 21); // returns 21
9、
时间: 2024-11-07 14:34:00