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. struct框架

    配置文件struct-config.xml<?xml version="1.0"encoding="UTF-8"?><!DOCTYPE str ...

  2. 19_传智播客iOS视频教程_类和对象

    什么是类?什么是对象? 看的见.摸的着.拿过来就可以直接使用.例如报纸就是一个对象. 学生这个东西可不可以只是指一个?就只有那一个才是学生.不是的,学生是有很多个的.它是对一类人的统称.类是统称.所以 ...

  3. bzoj 1715: [Usaco2006 Dec]Wormholes 虫洞【spfa判负环】

    tag是假的,用了及其诡异的方法判负环 正权无向边和负权有向边的图 #include<iostream> #include<cstdio> #include<cstrin ...

  4. 转 form表单中name和id区别

          HTML文本是由HTML命令组成的描述性文本,HTML命令可以说明文字.图形.动画.声音.表格.链接等.HTML的结构包括头部(Head).主体(Body)两大部分,其中头部描述浏览器所需 ...

  5. [转]How can I get my webapp's base URL in ASP.NET MVC

    本文转自:http://stackoverflow.com/questions/1288046/how-can-i-get-my-webapps-base-url-in-asp-net-mvc May ...

  6. 15 C#中的条件执行,if else

    在这一节的练习中,给大家介绍C#编程中的一个重要部分,条件执行.也就是If else语句.我们现实生活中的很多复杂的推理都可以用这个语法实现. If else语句的常规的样子,如下面所示. if (测 ...

  7. LN : leetcode 258 Add Digits

    lc 258 Add Digits lc 258 Add Digits Given a non-negative integer num, repeatedly add all its digits ...

  8. AngularJs与Java Web服务器交互

    AngularJs是Google工程师研发的产品,它的强大之处不是几句话就能描述的,只有真正使用过的人才能体会到,笔者准备在这篇文章中,以一个简单的登录校验的例子说明如何使用AngularJs和Web ...

  9. CSS 如何让li横向居中显示

    先给一个简单的示例HTML代码 <body> <form id="form1" runat="server"> <div id=& ...

  10. iOS布局分类

    1.线性布局: 2.集合布局: 3.单元布局: 需要考虑因素: 空间充足.空间不足时内容.尺寸的取舍.