Rumah > Artikel > hujung hadapan web > angularjs的内置函数你知道多少?angularjs的内置函数的介绍。
本篇文章主要的向大家介绍了关于angularjs的内置函数的介绍,还有很多angularjs支持的函数介绍。接下来就让我们一起来看这篇文章吧
我们一开始就来介绍angularjs的内置函数吧:
angular.lowercase:将字符串转换为小写
angular.uppercase:将字符串转换为大写
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']);
angular.isUndefined(value);判断value是否为undefined
angular.isObject(value);判断value是否为一个对象,不包括null
angular.isString(value);判断value是否为String类型
angular.isNumber(value);判断value是否为Number类型
angular.isDate(value);判断value是否为Date类型
angular.isArray(value);判断value是否为数组
angular.isFunction(value);判断value是否为函数类型
angular.isElement(value);判断value是否为一个DOM元素,包括JQuery封装的DOM
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(想看更多就到PHP中文网AngularJS开发手册中学习)
支持以下函数:
<span style="background-color:inherit;color:rgb(51,51,51);">addClass</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">after</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">append</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">attr</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
-
Does not support functions as parameters
<span style="background-color:inherit;color:rgb(51,51,51);">bind</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
-
Does not support namespaces, selectors or eventData
<span style="background-color:inherit;color:rgb(51,51,51);">children</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
-
Does not support selectors
<span style="background-color:inherit;color:rgb(51,51,51);">clone</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">contents</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">css</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
-
Only retrieves inline-styles, does not call <span style="background-color:inherit;color:rgb(51,51,51);">getComputedStyle</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">data</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">detach</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">empty</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">eq</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">find</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
-
Limited to lookups by tag name
<span style="background-color:inherit;color:rgb(51,51,51);">hasClass</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">html</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">next</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
-
Does not support selectors
<span style="background-color:inherit;color:rgb(51,51,51);">on</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
-
Does not support namespaces, selectors or eventData
<span style="background-color:inherit;color:rgb(51,51,51);">off</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
-
Does not support namespaces or selectors
<span style="background-color:inherit;color:rgb(51,51,51);">one</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
-
Does not support namespaces or selectors
<span style="background-color:inherit;color:rgb(51,51,51);">parent</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
-
Does not support selectors
<span style="background-color:inherit;color:rgb(51,51,51);">prepend</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">prop</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">ready</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">remove</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">removeAttr</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">removeClass</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">removeData</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">replaceWith</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">text</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">toggleClass</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">triggerHandler</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
-
Passes a dummy event object to handlers.
<span style="background-color:inherit;color:rgb(51,51,51);">unbind</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
-
Does not support namespaces
<span style="background-color:inherit;color:rgb(51,51,51);">val</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
<span style="background-color:inherit;color:rgb(51,51,51);">wrap</span><span style="background-color:inherit;color:rgb(51,51,51);">()</span>
好了,本篇文章到这就结束了(想看更多就到PHP中文网AngularJS使用手册中学习),有问题的可以在下方留言提问。
Atas ialah kandungan terperinci angularjs的内置函数你知道多少?angularjs的内置函数的介绍。. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!