Angular中保存了很多的判断方法,可以用来验证对象是否符合某种要求,详细的参考代码样例即可

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://apps.bdimg.com/libs/angular.js/1.2.16/angular.min.js"></script>
</head>
<body ng-app="myApp">
<div ng-controller="myCtrl" id="test">
{{ isArray }} <br><br>
{{ isDate }} <br><br>
{{ isUnDefined }} <br>
{{ isDefined }} <br><br>
{{ DocumentisElement }} <br>
{{ DivisElement }} <br><br>
{{ isFunction }} <br><br><br>
{{ isNumber1 }} <br>
{{ isNumber2 }} <br>
{{ isNumber3 }} <br>
{{ isNumber4 }} <br><br>
{{ isObject1 }} <br>
{{ isObject2 }} <br>
{{ isObject3 }} <br>
{{ isObject4 }} <br><br>
{{ isString1 }} <br>
{{ isString2 }} <br>
{{ isString3 }} <br>
{{ isString4 }} <br><br>
</div>
<script type="text/javascript">
var app = angular.module("myApp",[]);
app.controller("myCtrl",function($scope){ var arr = ["1","2","3"];
$scope.isArray = angular.isArray(arr);//true var date = new Date();
$scope.isDate = angular.isDate(date);//true var UnDefined;
$scope.isUnDefined = angular.isUndefined(UnDefined);//true
var Defined = "";
$scope.isDefined = angular.isDefined(Defined);//true $scope.DocumentisElement = angular.isElement(document);//true
$scope.DivisElement = angular.isElement(document.getElementById("test"));//true $scope.isFunction = angular.isFunction(function(){});//true $scope.isNumber1 = angular.isNumber(4);//true
$scope.isNumber2 = angular.isNumber(4.3);//true
$scope.isNumber3 = angular.isNumber(10/0);//true
$scope.isNumber4 = angular.isNumber(null);//false $scope.isObject1 = angular.isObject(null);//false
$scope.isObject2 = angular.isObject(undefined);//false
$scope.isObject3 = angular.isObject(function(){});//false
$scope.isObject4 = angular.isObject(date);//true $scope.isString1 = angular.isString("value");//true
$scope.isString2 = angular.isString('fds');//true
$scope.isString3 = angular.isString(null);//false
$scope.isString4 = angular.isString(4);//false
});
</script>
</body>
</html>

AngularJS API之isXXX()的更多相关文章

  1. 搭建angularjs API文档站点

    提供一个国内可以访问的 angularjs API文档站点 http://i.frllk.com/ 文档直接在 github 上下载的: https://github.com/angular-cn/n ...

  2. 【16】AngularJS API

    AngularJS API API 意为 Application Programming Interface(应用程序编程接口). AngularJS 全局 API AngularJS 全局 API ...

  3. AngularJS API

    AngularJS 全局 API 用于执行常见任务的 JavaScript 函数集合 angular.lowercase() 转换字符串为小写 angular.uppercase() 转换字符串为大写 ...

  4. AngularJS API之$injector ---- 依赖注入

    在AngularJS中也有依赖注入的概念,像spring中的依赖注入,但是又有所不同.Spring中使用构造注入或者设值注入的方式,还需要做一些额外的操作,但是angular中只需要在需要的地方声明一 ...

  5. AngularJS API之bootstrap启动

    对于一般的使用者来说,AngularJS的ng-app都是手动绑定到某个dom元素.但是在一些应用中,这样就显得很不方便了. 绑定初始化 通过绑定来进行angular的初始化,会把js代码侵入到htm ...

  6. AngularJS API之copy深拷贝

    angular提供了一个可以复制对象的api--copy(source,destination),它会对source对象执行深拷贝. 使用时需要注意下面几点: 如果只有一个参数(没有指定拷贝的对象), ...

  7. AngularJS API之toJson 对象转为JSON

    toJson()能把对象序列化为json 方法讲解 这个方法最多支持2个参数: angular.toJson(obj, pretty); obj 是想要转换的对象, pretty 可以调节格式化的样式 ...

  8. AngularJS API之extend扩展对象

    angular.extend(dst,src),在我实验的1.2.16版本上是支持深拷贝的.但是最新的API显示,这个方法是不支持深拷贝的. 另外,第二个参数src支持多个对象. 第一种使用方式 va ...

  9. AngularJS API之equal比较对象

    使用情况 1 首先,所有满足 a === 3 这种的对象,在angular.equals(a,b)中都会返回真 2 所有对象的类型,以及属性值都相同的,也会返回真 3 NaN和NaN也会返回真(在ja ...

随机推荐

  1. 洛谷P1889 士兵站队

    题目描述 在一个划分成网格的操场上, n个士兵散乱地站在网格点上.由整数 坐标 (x,y) 表示.士兵们可以沿网格边上.下左右移动一步,但在同时刻任一网格点上只能有名士兵.按照军官的命令,们要整齐地列 ...

  2. linux查看某个进程的线程id(spid)

    鉴于linux下线程的广泛使用 我们怎么查看某个进程拥有的线程id了 现在很多服务的设计 主进程->子进程->线程(比如mysql,varnish) 主进程负责侦听网络上的连接 并把连接发 ...

  3. python实现自动输入命令回车操作

    苦逼的在sf上等了一天(问题链接),都没人来解答,只好自己想办法,东平西凑还是勉强实现了,记录一下: 安装完python2.7后,在cmd命令行输入python回车,后出现python相关的提示信息, ...

  4. WebStorm工具插件下载安装

    在webstorm工具中安装插件 ,找到File->Setting->Plugins  然后搜索你想要的插件安装即可. 例如,我们安装weex插件

  5. BeautifulSoup高级应用 之 CSS selectors /CSS 选择器

    BeautifulSoup支持最常用的CSS selectors,这是将字符串转化为Tag对象或者BeautifulSoup自身的.select()方法. 本篇所使用的html为: html_doc ...

  6. Mysql学习笔记(五)数据查询之测试sql部分。

    正文之前,介绍mysql一些很有趣的命令. 快速的创建表,并填充表数据. create table test like  已经有的表名: inset into test select * from f ...

  7. BZOJ3207: 花神的嘲讽计划Ⅰ

    显然hash,然后stl随便搞. #include<bits/stdc++.h> #define N 100005 using namespace std; typedef unsigne ...

  8. 【原】React中,map出来的元素添加事件无法使用

    在使用react中,经常用到react的map函数,用法和jquery里中的map一样,但是,如果你在每个map出来的元素中添加,你会发觉添加的事件无法关联, 比如,我们很多的评论,我需要在每个评论下 ...

  9. wcf第2步之服务端标准配置文件

    服务端app.config <?xml version="1.0" encoding="utf-8" ?><configuration> ...

  10. Datatable的Select()

    利用datatable的select方法筛选出符合条件的datarow进行操作 Select() Select(string filterExpression) Select(string filte ...