标签:
1 2 3 4 | var myApp = angular.module(‘myApp‘, []);//ng-app模块化,[]内为依赖的其他模块myApp.controller(‘Aaa‘, [‘$scope‘, function ($scope) { $scope.name = ‘hello‘;}]); |
1 2 3 4 5 6 7 8 | function show(n1, n2) { alert(n1); alert(n2); alert(this);}angular.bind(document, show, 3)(4);//- > $.proxy():改this指向angular.bind(document, show, 3, 4)();angular.bind(document, show)(3, 4); |
1 2 3 4 5 6 7 8 9 | var a = { name: ‘hello‘};var b = { age: ‘20‘};var c = angular.copy(a, b); //拷贝对象,a把所有值覆盖给了bconsole.log(b);console.log(c); |
1 2 3 4 5 6 7 8 9 | var a = { name: ‘hello‘};var b = { age: ‘20‘};var c = angular.extend(b, a);//对象继承console.log(b);console.log(c); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | var a = [];console.log(angular.isArray(a));//判断是否为数组angular.isArray;angular.isDate;angular.isDefined;angular.isUndefined;angular.isFunction;angular.isNumber;angular.isObject;angular.isString;angular.isElement;angular.version;//获取AngularJS版本var a = 1;var b = 1;console.log(angular.equals(a, b));//比较,与==稍有不同,var values = [‘a‘, ‘b‘, ‘c‘];var values = {‘name‘: ‘hello‘, ‘age‘: ‘20‘};var result = [];angular.forEach(values, function (value, i) {//第一个参数:值,第二个参数:下标或字段名 console.log(value); console.log(i); this.push(value + i);}, result);//第三个参数为返回值,this为第三个参数console.log(result);var str = ‘{"name":"hello","age":"20"}‘;var json = angular.fromJson(str);//相当于原生JSON.parse(),把字符串转化为jsonconsole.log(json);var json = {"name": "hello", "age": "20"};var str = angular.toJson(json, true);//相当于原生JSON.stringify(),把json转化为字符串,第二个参数为true表示字符串格式化console.log(str);var str = ‘hello‘;console.log(angular.identity(str));//输出hello,相当于下面函数,没用function identity(str) { return str;}console.log(angular.noop()); //输出undefined,空函数,没用function noop() {}angular.lowercase(‘HELLO‘);//转小写angular.uppercase(‘hello‘);//转大写var oDiv = document.getElementById(‘div1‘);angular.element(oDiv).css(‘background‘, ‘red‘); |
标签:
原文地址:http://www.cnblogs.com/wayraki/p/5547965.html