AngularJS API


API 意为 Application Programming Interface(应用程序编程接口)。


AngularJS 全局 API

AngularJS 全局 API 用于执行常见任务的 JavaScript 函数集合,如:

  • 比较对象
  • 迭代对象
  • 转换对象

全局 API 函数使用 angular 对象进行访问。

以下列出了一些通用的 API 函数:

API 描述
angular.lowercase() 转换字符串为小写
angular.uppercase() 转换字符串为大写
angular.isString() 判断给定的对象是否为字符串,如果是返回 true。
angular.isNumber() 判断给定的对象是否为数字,如果是返回 true。

angular.lowercase()

  1. <div ng-app="myApp" ng-controller="myCtrl">
  2. <p>{{ x1 }}</p>
  3. <p>{{ x2 }}</p>
  4. </div>
  5. <script>
  6. var app = angular.module('myApp',[]);
  7. app.controller('myCtrl',function($scope){
  8. $scope.x1 ="JOHN";
  9. $scope.x2 = angular.lowercase($scope.x1);
  10. });
  11. </script>
结果:

angular.uppercase()

  1. <div ng-app="myApp" ng-controller="myCtrl">
  2. <p>{{ x1 }}</p>
  3. <p>{{ x2 }}</p>
  4. </div>
  5. <script>
  6. var app = angular.module('myApp',[]);
  7. app.controller('myCtrl',function($scope){
  8. $scope.x1 ="John";
  9. $scope.x2 = angular.uppercase($scope.x1);
  10. });
  11. </script>
结果:

angular.isString()

  1. <div ng-app="myApp" ng-controller="myCtrl">
  2. <p>{{ x1 }}</p>
  3. <p>{{ x2 }}</p>
  4. </div>
  5. <script>
  6. var app = angular.module('myApp',[]);
  7. app.controller('myCtrl',function($scope){
  8. $scope.x1 ="JOHN";
  9. $scope.x2 = angular.isString($scope.x1);
  10. });
  11. </script>
结果:

angular.isNumber()

  1. <div ng-app="myApp" ng-controller="myCtrl">
  2. <p>{{ x1 }}</p>
  3. <p>{{ x2 }}</p>
  4. </div>
  5. <script>
  6. var app = angular.module('myApp',[]);
  7. app.controller('myCtrl',function($scope){
  8. $scope.x1 ="JOHN";
  9. $scope.x2 = angular.isNumber($scope.x1);
  10. });
  11. </script>
结果:
 
 
 

【16】AngularJS API的更多相关文章

  1. 企业IT管理员IE11升级指南【16】—— 使用Compat Inspector快速定位IE兼容性问题

    企业IT管理员IE11升级指南 系列: [1]—— Internet Explorer 11增强保护模式 (EPM) 介绍 [2]—— Internet Explorer 11 对Adobe Flas ...

  2. LeetCode:字母异位词分组【16】

    LeetCode:字母异位词分组[16] 题目描述 给定一个字符串数组,将字母异位词组合在一起.字母异位词指字母相同,但排列不同的字符串. 示例: 输入: ["eat", &quo ...

  3. LeetCode:最接近的三数之和【16】

    LeetCode:最接近的三数之和[16] 题目描述 给定一个包括 n 个整数的数组 nums 和 一个目标值 target.找出 nums 中的三个整数,使得它们的和与 target 最接近.返回这 ...

  4. 【译】Android API 规范

    [译]Android API 规范 译者按: 修改R代码遇到Lint tool的报错,搜到了这篇文档,aosp仓库地址:Android API Guidelines. 58e9b5f Project ...

  5. 【VLC-Android】LibVLC API简介(相当于VLC的MediaPlayer)

    前言 学新东西API很重要,这里抛砖引玉整理了一下,欢迎反馈! 声明 欢迎转载,但请保留文章原始出处:)  博客园:http://www.cnblogs.com 农民伯伯: http://over14 ...

  6. 【转】vc api 录音

    一.数字音频基础知识 Fourier级数: 任何周期的波形可以分解成多个正弦波,这些正弦波的频率都是整数倍.级数中其他正线波的频率是基础频率的整数倍.基础频率称为一级谐波. PCM: pulse co ...

  7. 【转】Android API 中文(14) —— ViewStub

    用一个XML源填充view.inflate(上下文对象,资源文件Id,父窗口组一般为null): 原文网址:http://www.cnblogs.com/over140/archive/2010/10 ...

  8. CMDB服务器管理系统【s5day90】:API验证

    1.认证思路刨析过程 1.请求头去哪里拿? 1.服务器端代码: def test(request): print(request) return HttpResponse('你得到我了') 2.客户端 ...

  9. 【Web】Rest API 验证授权如何做?

    参考资料: [Web]Rest && 权限管理等:http://www.itdadao.com/2016/03/15/593144/ 无需OAuth就可以设计一个安全的REST (We ...

随机推荐

  1. Python 常用算法记录

    一.递归 汉诺塔算法:把A柱的盘子,移动到C柱上,最少需要移动几次,大盘子只能在小盘子下面 1.当盘子的个数为n时,移动的次数应等于2^n – 1 2.描述盘子从A到C: (1)如果A只有一个圆盘,可 ...

  2. Enum类的非一般用法汇总(工作中遇到时持续更新)

    1.  每个枚举实例定义一套自己的方法示例: 1 @AllArgsConstructor 2 public enum BroadcastTypeEnum { 3 ALL(0, "全站&quo ...

  3. bzoj 1026: [SCOI2009]windy数【数位dp】

    忘记limit不能记WA了一发-- 典型数位dp,变成work(r)-work(l-1),然后dfs的时候记录w当前位置,la上一个数选的什么,lm当前位是否有上限,ok当前位是否可以不考虑差大于等于 ...

  4. typescript进阶篇之高级类型与条件类型(Readonly, Partial, Pick, Record)

    本文所有东西尽可在 typescript 官网文档寻找,但是深浅不一 高级类型 lib 库中的五个高级类型 以下所有例子皆以 person 为例 interface Person { name: st ...

  5. xshell、xftp最新版下载方法

    https://www.netsarang.com/download/main.html 登录邮箱打开第一个下载地址进行下载

  6. 构造 Codeforces Round #135 (Div. 2) B. Special Offer! Super Price 999 Bourles!

    题目传送门 /* 构造:从大到小构造,每一次都把最后不是9的变为9,p - p MOD 10^k - 1,直到小于最小值. 另外,最多len-1次循环 */ #include <cstdio&g ...

  7. 解决FormClosing事件点击关闭2次的问题

    以下代码:提示框会跳出2遍  private void mFrmmain_FormClosing(object sender, FormClosingEventArgs e) { if (Dialog ...

  8. SAS进阶《深入分析SAS》之数据汇总和展现

    SAS进阶<深入分析SAS>之数据汇总和展现 1. 通过Print过程制作报表 proc print <data=数据集>; run; 选项: obs=修改观测序号列标签 no ...

  9. Android 简单的语音播报

    不解释快上车 Main.class package com.example.myapp; import android.app.AlertDialog;import android.os.Bundle ...

  10. Android基础TOP5_4:点击按钮更换样式,设置透明度

    在res/drawable创建两个样式 点击前/点击后 round: <?xml version="1.0" encoding="utf-8"?> ...