标签:angularjs
#angularjs判断类型函数 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <script src="js/angular.min.js"></script> </head> <body> <div ng-app="app" ng-controller="ctrl"> </div> <script type="text/javascript"> var m=angular.module(‘app‘,[]); m.controller(‘ctrl‘,[‘$scope‘,function($scope){ //angular.isArray 判断是否为数组 console.log(‘angular.isArray([]):‘+angular.isArray([])) //angular.isDate 判断是否为Data类型 console.log(‘angular.isDate(new Date()):‘+angular.isDate(new Date())) //angular.isDefined和angular.isUndefined 判断数据是否定义 console.log(‘angular.isDefined("abcd"):‘+angular.isDefined("abcd")) console.log(‘angular.isDefined():‘+angular.isDefined()) console.log(‘angular.isUndefined("abcd"):‘+angular.isUndefined("abcd")) console.log(‘angular.isUndefined():‘+angular.isUndefined()) //angular.isFunction 判断是否为函数 console.log(‘angular.isFunction(function(){}):‘+angular.isFunction(function(){})) //angular.isNumber 判断是否为数字 console.log(‘angular.isNumber(1):‘+angular.isNumber(1)) //angular.isString 判断是否为字符串 console.log(‘angular.isString("abcd"):‘+angular.isString(‘abcd‘)) //angular.isObject() 判断是否为对象 console.log(‘angular.isObject({}):‘+angular.isObject({})) //angular.isElement() 判断是否为dom元素 console.log(‘angular.isElement(document.getElementsByTagName("body").item(0)):‘+angular.isElement(document.getElementsByTagName(‘body‘).item(0))) //angular.equals 判断是否相等 console.log(‘angular.equals(["abcd"],["abcd"]):‘+angular.equals(["abcd"],["abcd"])) }]); </script> </body> </html>
标签:angularjs
原文地址:http://f1yinsky.blog.51cto.com/12568071/1955946