angularjs之函数

来源:互联网 发布:兰蔻臻白精华乳 知乎 编辑:程序博客网 时间:2024/06/05 11:39


  1. angular.lowercase:将字符串转换为小写
  2. angular.uppercase:将字符串转换为大写
  3. angular.forEach(obj, iterator, [context]):遍历对象集合,该函数包括三个参数,第一个参数表示需要遍历的对象或数组,第二个参数为一个函数,第三个对象为当前的上下文环境(this);
    var values = {name: 'misko', gender: 'male'};var log = [];angular.forEach(values, function(value, key) {  this.push(key + ': ' + value);}, log);expect(log).toEqual(['name: misko', 'gender: male']);


  4. angular.isUndefined(value);判断value是否为undefined
  5. angular.isObject(value);判断value是否为一个对象,不包括null
  6. angular.isString(value);判断value是否为String类型
  7. angular.isNumber(value);判断value是否为Number类型
  8. angular.isDate(value);判断value是否为Date类型
  9. angular.isArray(value);判断value是否为数组
  10. angular.isFunction(value);判断value是否为函数类型
  11. angular.isElement(value);判断value是否为一个DOM元素,包括JQuery封装的DOM
  12. angular.equals(o1, o2);判断两个对象是否相等
        满足下列条件之一的,都视为两个对象相等。
  •         o1===o2 返回true
  •         o1和o2的所有属性通过angular.equals比较都相等
  • o1,o2都是NAN
  • 两个同样的正则(/abc/=/abc/)     在JavaScript中返回false,在angular中返回true
13.angular.toJson(obj, pretty);将对象转换为json,obj:需要转换的对象,pretty:true或一个数字,true表示保留对象属性值中的空格和换行,设置为一个数字表示去掉空格和换行。默认值为2,即去除空格和换行。
14.angular.fromJson(json);将一个json字符串,转换为一个对象或对象数组。
15.angular.element(element);将一个原生DOM或HTML字符串包裹为一个JQuery对象。


angularjs内置了一个迷你版的JQuery,JQlite

支持以下函数:
  • addClass()
  • after()
  • append()
  • attr() - Does not support functions as parameters
  • bind() - Does not support namespaces, selectors or eventData
  • children() - Does not support selectors
  • clone()
  • contents()
  • css() - Only retrieves inline-styles, does not call getComputedStyle()
  • data()
  • detach()
  • empty()
  • eq()
  • find() - Limited to lookups by tag name
  • hasClass()
  • html()
  • next() - Does not support selectors
  • on() - Does not support namespaces, selectors or eventData
  • off() - Does not support namespaces or selectors
  • one() - Does not support namespaces or selectors
  • parent() - Does not support selectors
  • prepend()
  • prop()
  • ready()
  • remove()
  • removeAttr()
  • removeClass()
  • removeData()
  • replaceWith()
  • text()
  • toggleClass()
  • triggerHandler() - Passes a dummy event object to handlers.
  • unbind() - Does not support namespaces
  • val()
  • wrap()
                                       
            

0 0