<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>
<body ng-app="myApp" ng-controller="myCtrl"> <div >
<p>名字 : <input type="text" ng-model="firstName" ng-bind="firstName"></p>
<p>名字 : <input type="text" ng-model="lastName" ng-bind="lastName"></p>
<p>输入过滤 : <input type="text" ng-model="text" ng-bind="text"></p>
<p>当前页面地址 : <span>{{pageUrl}}</span></p>
<p>Get请求返回 : <span>{{response}}</span></p>
<span>延迟执行:{{timeOutState}}</span>
<span>当前时间:{{dateTime}}</span> <span>{{(firstName|lowercase)+" "+lastName}}</span>
<span>{{5|currency}} </span> </div>
<ul>
<li ng-repeat="x in names |filter: text |orderBy:country">
{{x.name+','+(x.country|reverse)}}
</li>
</ul>
<script>
//angular使用内置服务展示 服务对象需要传递参数接收 只要参数名称对的上就行
var app = angular.module('myApp', []);
app.controller('myCtrl', function ($scope, $location, $http, $timeout, $interval) {
//执行一个请求 回调在then中执行 延续了jq风格将异步操作线性编写完成
$http.get("Handler1.ashx").then(function (response) {
$scope.response = response.data; }); $scope.firstName = "firstName";
$scope.lastName = "lastName";
$scope.names = [
{ 'name': 's1', 'country': 'china' },
{ 'name': 's2', 'country': 'america' },
{ 'name': 5, 'country': 'america' }, ];
//$location服务使用 获取当前页面的完整url
$scope.pageUrl = $location.absUrl();
//执行一个延迟执行函数
$timeout(function () {
$scope.timeOutState = '执行成功';
}, 3000);
//执行一个定时器
$interval(function () {
$scope.timeOutState = (new Date());
}, 1000) });
//自定义一个过滤器反转字符顺序的过滤器
app.filter('reverse', function () {
return function (text) {
return text.split("").reverse().join("");
} })
</script> </body>
</html>

  

angularJS使用内置服务的更多相关文章

  1. AngularJS复习-----内置过滤器和内置服务

    AngularJS中的内置服务(共30多个): $http 发送http请求,主要用于进行异步数据请求的功能实现,这个服务主要封装了XMLHttpRequest对象和JSONP数据访问模式来完成远程请 ...

  2. Angular 基本内置服务和筛选器

    AngularJS中的内置服务(共30多个): $http 发送http请求,主要用于进行异步数据请求的功能实现,这个服务主要封装了XMLHttpRequest对象和JSONP数据访问模式来完成远程请 ...

  3. Hive基础(4)---Hive的内置服务

    版权声明:<—— 本文为作者呕心沥血打造,若要转载,请注明出处@http://blog.csdn.net/gamer_gyt <——   目录(?)[+]   一:Hive的几种内置服务 ...

  4. Hive 学习笔记(启动方式,内置服务)

    一.Hive介绍 Hive是基于Hadoop的一个数据仓库,Hive能够将SQL语句转化为MapReduce任务进行运行. Hive架构图分为以下四部分. 1.用户接口 Hive有三个用户接口: 命令 ...

  5. 学习angularjs的内置API函数

    angularjs的内置API函数有很多,如isString()判断给定的对象是否为字符串,如果是返回 true,反之返回false:isNumber()判断给定的对象是否为数字,如果是返回 true ...

  6. 夺命雷公狗—angularjs—15—内置封装好的计时器$interval和$timeout

    这里其实和js源生的效果是一样的,但是源生的在angularjs里面不能直接正常执行代码如下所示: <!DOCTYPE html> <html lang="en" ...

  7. ASP.NET Core MVC内置服务的使用

    ASP.NET Core中的依赖注入可以说是无处不在,其通过创建一个ServiceCollection对象并将服务注册信息以ServiceDescriptor对象的形式添加在其中,其次针对Servic ...

  8. Angular——内置服务

    $location <!DOCTYPE html> <html lang="en" ng-app="App"> <head> ...

  9. 前端MVC学习总结(三)——AngularJS服务、路由、内置API、jQueryLite

    一.服务 AngularJS功能最基本的组件之一是服务(Service).服务为你的应用提供基于任务的功能.服务可以被视为重复使用的执行一个或多个相关任务的代码块. AngularJS服务是单例对象, ...

随机推荐

  1. 【Floyd】POJ2139 -Six Degrees of Cowvin Bacon

    普通的Floyd了分分秒可以水过,结果在submit前删调试段落的时候把程序本体给删了吃了两个WA…… #include<iostream> #include<cstring> ...

  2. 1.3 (JavaScript学习笔记)JavaScript对象

    在JavaScript中所有事物都是对象,字符串.数值.数组.函数...等, JavaScript还允许自定义对象.这些在1.1中有所介绍. 一.遍历对象属性 <!DOCTYPE html> ...

  3. Problem E: 12306

    #include <stdio.h> struct student{ int n; int m;}; int main(void) { int T; int k,g,i,j; ],max; ...

  4. Eclipse运行Maven的SpringMVC项目Run on Server时出现错误:Error configuring application listener of class org.springframework.web.context.ContextLoaderListener的问题解决

    错误: 严重: Error configuring application listener of class org.springframework.web.context.ContextLoade ...

  5. ecplise配置maven项目

    1.新增环境变量 M2_HOME C:\Users\Administrator\Desktop\Java\maven\apache-maven-3.3.1   2.配置PATH路径 ;%M2_HOME ...

  6. WindowsServices_无法拷贝文件到服务器

    方法一:驱动器勾选   方法二:rdpclip.exe进程 1.现在进程管理中结束所有的rdpclip.exe进程 2.在运行中执行 rdpclip.exe接口    

  7. phpok -- 域名问题

    nginx会改变连接的baseurl, 所以要改变nginx的server name的配置. 将网站改为静态也需配置nginx.

  8. Hibernate 注解@Column(nullable = false) 和 @Column(unique=true)

    unique=true是指这个字段的值在这张表里不能重复,所有记录值都要唯一,就像主键那样; nullable=false是这个字段在保存时必需有值,不能还是null值就调用save去保存入库;

  9. PostgreSQL配置文件--其他

    9 CLIENT CONNECTION DEFAULTS 9.1 Statement Behavior 9.1.1 search_path 字符型 默认:search_path = '"$u ...

  10. mac远程链接 windows

    https://bbs.feng.com/read-htm-tid-10516042.html 一.利用电脑系统自带的远程(喜欢懒人版的方法,或者小白用户,可以跳过这个方法看下一个) 1.打开mac, ...