標籤:color copy foreach inpu add end fine san for
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");//trueconsole.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 42getResult(null, 21); // returns 21getResult(undefined, 21); // returns 21
9、
angularjs英文版api學習 (附demo)