写在前面
在angularjs中提供了一些常用的函数,比如angular.lowercase(),angular.uppercase(),angular.isString(),angular.isNumber()。
demo
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="../Scripts/angular.min.js"></script>
<script>
var app = angular.module('myapp', []);
app.controller("myCtrl", function ($scope) { //控制器
var name = "WOLFY"; //转换字符串为小写
var lower = angular.lowercase(name);
console.log(lower); //转换字符串为大写
var upper = angular.uppercase(lower);
console.log(upper); //判断给定的对象是否为字符串,如果是返回 true。 console.log(angular.isString(name)); //判断给定的对象是否为数字,如果是返回 true。 console.log(angular.isNumber(name)); //是否是undefined console.log(angular.isUndefined(name)); //是否是array console.log(angular.isArray(name)); //是否为date console.log(angular.isDate(name)); //是否defined console.log(angular.isDefined(name)); //是否是element console.log(angular.isElement(name)); //是否是function console.log(angular.isFunction(name)); //是否是object console.log(angular.isObject(name));
console.log(angular.isPrototypeOf(name));
}); </script></head><body>
<div ng-controller="myCtrl">
</div></body></html>
结果