AngularJS API之isXXX()
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()的更多相关文章
- 搭建angularjs API文档站点
提供一个国内可以访问的 angularjs API文档站点 http://i.frllk.com/ 文档直接在 github 上下载的: https://github.com/angular-cn/n ...
- 【16】AngularJS API
AngularJS API API 意为 Application Programming Interface(应用程序编程接口). AngularJS 全局 API AngularJS 全局 API ...
- AngularJS API
AngularJS 全局 API 用于执行常见任务的 JavaScript 函数集合 angular.lowercase() 转换字符串为小写 angular.uppercase() 转换字符串为大写 ...
- AngularJS API之$injector ---- 依赖注入
在AngularJS中也有依赖注入的概念,像spring中的依赖注入,但是又有所不同.Spring中使用构造注入或者设值注入的方式,还需要做一些额外的操作,但是angular中只需要在需要的地方声明一 ...
- AngularJS API之bootstrap启动
对于一般的使用者来说,AngularJS的ng-app都是手动绑定到某个dom元素.但是在一些应用中,这样就显得很不方便了. 绑定初始化 通过绑定来进行angular的初始化,会把js代码侵入到htm ...
- AngularJS API之copy深拷贝
angular提供了一个可以复制对象的api--copy(source,destination),它会对source对象执行深拷贝. 使用时需要注意下面几点: 如果只有一个参数(没有指定拷贝的对象), ...
- AngularJS API之toJson 对象转为JSON
toJson()能把对象序列化为json 方法讲解 这个方法最多支持2个参数: angular.toJson(obj, pretty); obj 是想要转换的对象, pretty 可以调节格式化的样式 ...
- AngularJS API之extend扩展对象
angular.extend(dst,src),在我实验的1.2.16版本上是支持深拷贝的.但是最新的API显示,这个方法是不支持深拷贝的. 另外,第二个参数src支持多个对象. 第一种使用方式 va ...
- AngularJS API之equal比较对象
使用情况 1 首先,所有满足 a === 3 这种的对象,在angular.equals(a,b)中都会返回真 2 所有对象的类型,以及属性值都相同的,也会返回真 3 NaN和NaN也会返回真(在ja ...
随机推荐
- Linux Crontab 定时任务 命令详解
一. Crontab 介绍 crontab命令的功能是在一定的时间间隔调度一些命令的执行. 1.1 /etc/crontab 文件 在/etc目录下有一个crontab文件,这里存放有系统运行的一些调 ...
- Android数据存储-文件操作
一.预备知识 1.Android中的MVC设计模式 MVC (Model-View-Controller):M是指逻辑模型,V是指视图模型,C则是控制器.一个逻辑模型可以对于多种视图模型,比如一批统计 ...
- Uva11464 Even Parity
枚举每个格子的状态显然是不可能的. 思考发现,矩阵第一行的状态确定以后,下面的状态都可以递推出来. 于是状压枚举第一行的状态,递推全图的状态并判定是否可行. /*by SilverN*/ #inclu ...
- 洛谷P1595 信封问题
题目描述 某人写了n封信和n个信封,如果所有的信都装错了信封.求所有信都装错信封共有多少种不同情况. 输入输出格式 输入格式: 一个信封数n 输出格式: 一个整数,代表有多少种情况. 输入输出样例 输 ...
- nagios note
server: nagios nagios_plugin nrpe ip:192.168.1.2 client nagios_plugin xinetd nrpe ip:192.168.1.3 一篇介 ...
- Unity 依赖注入知识点
三种依赖注入方法,构造器注入.属性注入.方法注入 可以配置Config文件,来实现不用修改代码.需要先将接口与实体关联,然后使用时会自动加载对应实体. namespace WeChatConsole ...
- K米APP案例分析
关于 K米 -- 的案例分析 产品 K米的APP (全国KTV点歌,手机直播,互动,交友,预订)的Android客户端 第一部分 调研,评测 评测: 软件的bug,功能评测,黑箱测试 • 下载并使用, ...
- 我所了解的meta
https://github.com/hoosin/mobile-web-favorites 总况 meta 标签分两大部分:HTTP 标题信息(http-equiv)和页面描述信息(name). h ...
- linux中运维相关命令
1.awk 可以参考:http://www.itshouce.com.cn/linux/linux-awk.html 1.1 常见语法 cat test.txt | awk 'BEGIN{print ...
- JavaScript中局部变量与全局变量的不同
JavaScript中局部变量与全局变量 我们知道,JavaScript的变量是松散型的变量,也就是说,其变量只需用var声明,其赋值的类型是不限定的.比如: var person=18; perso ...