AngularJS工具的使用方法是什么?AngularJS中如何使用jQuery?

本篇文章主要的向大家介绍了关于angularjs的工具使用的方法和angularjs中使用jQuery的详情,我们一起来看看这篇文章吧。

 1. Angularjs 工具方法

(1)angular.isarray(value) 判断是否是数组,返回true/false

{{isArray}}

登录后复制

$scope.arr=[1,2,3];$scope.isArray=angular.isArray($scope.arr);

登录后复制

(2)angular.isDate(value) 判断是否是日期类型,返回true/false

(3)angular.idDefined(value) 判断是否被定义了,返回true/false

(4)angular.isElement(node) 判断是否是DOM节点,返回true/false

(5)angular.isFunction(value) 判断是否是Function类型,返回true/false

(6)angular.isNumber(value) 判断是否是Number类型,其中包括NaN,Infinity和-Infinity,返回true/false

(7)angular.isObject(value) 判断是否是Object类型,Array是Objct类型,Null不是Object类型,返回true/false

(8)angular.isString(value) 判断是否是字符串类型,返回true/false

(9)angular.uppercase(value) 转换成大写

{{name1}}

登录后复制

 $scope.name='zhangsan'; $scope.name1=angular.uppercase($scope.name);

登录后复制

(10)angular.lowercase(value) 转换成小写

(11)angular.equals(o1,o2) 判断两个字符串是否相等,返回true/false

{{eq}}

登录后复制

$scope.a='111';$scope.b='111';$scope.eq=angular.equals($scope.a,$scope.b);

登录后复制

(12)angular.extend(dst,src) 继承关系,如下代码所示,b继承了a的属性

$scope.a={name:'张三'};$scope.b={age:10};$scope.c=angular.extend($scope.b,$scope.a);console.log($scope.b);//{"age":10,"name":"张三"}

登录后复制

(13)angular.fromJson(json) 反序列化json字符串,把json字符串转换成JavaScript Object对象

 var json = '{"name":"hello","age":"20"}'; console.log(json); $scope.json=angular.fromJson(json); console.log($scope.json);

登录后复制

36.png

(14)angular.toJson(obj,pretty) 格式化json字符串

 var json = {"name":"hello","age":"20"}; // console.log(json); // $scope.json=angular.toJson(json); $scope.json=angular.toJson(json,true); console.log($scope.json);

登录后复制

35.png(15)angular.copy(source, [destination]) 如下代码所示,把a复制给b

              $scope.a={name:'张三'};              $scope.b={age:10};              $scope.c=angular.copy($scope.a,$scope.b);              console.log($scope.a);              console.log($scope.b);

登录后复制

34.png(16)angular.forEach(obj, iterator, [context]) 

              var json = {"name":"hello","age":"20","sex":'男'};              angular.forEach(json,function(val,key){                    //console.log(val);                  console.log(key);              });

登录后复制

33.png

              var json = {"name":"hello","age":"20","sex":'男'};              var results=[];             angular.forEach(json,function(val,key){                  //console.log(val);                  //console.log(key);                  this.push(key+'--'+val);              },results);              console.log(results);

登录后复制

(17)angular.bind(self, fn, args);绑定对象,作为函数的上下文

              var self={name:'张三'};              var f=angular.bind(self,function(age){                        $scope.info=this.name+' is '+age;                        console.log($scope.info);              });              f(30);              var f=angular.bind(self,function(age){                  $scope.info=this.name+' is '+age;                 console.log($scope.info);              },10);              f();

登录后复制

31.png本篇文章到这就结束了(想看更多就到PHP中文网AngularJS使用手册中学习),有问题的可以在下方留言提问。

以上就是AngularJS工具的使用方法是什么?AngularJS中如何使用jQuery?的详细内容,更多请关注【创想鸟】其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。

发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2741960.html

(0)
上一篇 2025年3月8日 02:43:10
下一篇 2025年3月5日 17:54:01

AD推荐 黄金广告位招租... 更多推荐

相关推荐

发表回复

登录后才能评论