[javascript] view plain copy
- //判断是否是个数组
- angular.isArray([])//true
- angular.isArray("strings")//false
- //判断是否是个日期对象
- var a = angular.isDate(new Date());//true
- //判断一个值是否被定义
- angular.isDefined(undefined);//false
- angular.isDefined([])//true
- //和defined刚好相反
- angular.isUndefined(undefined);//true
- //angular.isElement 确定是否是一个dom元素,或者jq对象
- angular.isElement()
- //angualr.isFunction 确定是否是个方法
- angular.isFunction(function(){});//true
- //angular.isNumber 确定是否是个数字
- angular.isNumber(1);//true
- //angular.isObject 确定是否是个对象
- angular.isObject(null)//false
- angular.isObject([])//true
- //angular.isString 确定是否是字符串
- angular.isString("abc")//true
[javascript] view plain copy
- angular.uppercase(string);//将所有的英文字母大写
- angular.lowercase(string);//转换指定的字符串为小写。
- angular.equals(o1, o2);//确定两个对象或两个值是相等的。支持值类型,正则表达式,数组和对象。
- angular.extend(目标对象, Source对象);//浅拷贝,不支持深拷贝
- angular.fromJson(json);//处理json,返回Json字符串
- angular.toJson(json_string)//传入json字符串,返回json对象
- angular.copy(a,b)//将b的引用改为a的引用,相当于b=a
[javascript] view plain copy
- //angular.forEach 遍历数组和对象
- angular.forEach(遍历对象,function(val,key){
- ....
- },这里可以有第三个参数写了function里面的this就会指向这个对象)
- angular.bind()//绑定函数,作为函数的上下文
- angular.bind(self, fn, args);
- self 绑定的对象
- fn 方法
- args 向方法里面传入的变量
- var a = {name:"zhangsan"};
- 第一种
- var f = angular.bind(a,function(age){
- console.log(this.name+"age is"+age);
- },10)
- f();
- 第二种
- var f = angular.bind(a,function(age){
- console.log(this.name+"age is"+age);
- })
- f(10);
[javascript] view plain copy
- angular.bootstrap()//方法用于手动初始化angular
- angular.bootstrap(element, [modules], [config]);
- element dom元素
- modules 模块加载需要引入的模块
- config 对象用于定义应用程序的配置选项
- angular.module()//方法用于创建,注册和检索modele
- angular.bootstrap(element, [modules], [config]);
- element ng-app的值
- modules 模块加载需要引入的模块
- config 对象用于定义应用程序的配置选项