AngularJS提供了如下的一下常用函数
| API名称 | 描述 |
| anguler.lowercase() | 转换为小写字母 |
| anguler.uppercase() | 转换为大写字母 |
| angular,.isString() | 是否为字符串 |
| isNumber | 是否为数字 |
完整的一个例子:
<div ng-app="demo" ng-controller="mycontroller">
<input type="text" ng-model="inutStr"></input>
<p>input string is {{inpuStr}}</p>
<p>to lowercase is:{{lowercaseStr}}</p>
<p>to uppercase is:{{uppercaseStr}}</p>
<p ng-switch="isStr">is String:
<label ng-switch-when="true">yes</label>
<label ng-switch-when="false">No</label>
</p>
<p ng-switch="isNum">is Number:
<label ng-switch-when="true">yes</label>
<label ng-switch-when="false">No</label>
</p>
</div>
<script>
var app=angular.module("demo",[]);
app.controller("mycontroller",function($scope){
$scope.lowercaseStr=angular.lowercase($scope.inputStr);
$scope.uppercaseStr=angular.uppercase($scope.inputstr);
$scope.isStr=angular.isString($scope.input);
//$scope.isNum=angualr.isnum($scope.input);
});
</script>
本文详细介绍了AngularJS中常用的函数,如转换大小写、判断字符串和数字类型的功能,并通过一个完整的示例展示了如何在实际应用中使用这些函数。
325

被折叠的 条评论
为什么被折叠?



