AngularJS Server

Service components in ng

$location server 

解析浏览器中的URL (基于window.location)并使URL可用于应用程序。改变地址栏的URL将反映到$location server 并将更改$location 反映到浏览器地址栏中。

$locating 类似window.location 对象,但AngularJS 会实时监控应用,window.location 存在一定的局限性,所以使用$location 对象更好

$location server

A   在浏览器地址显示当前URL --- 观察URL 、改变URL

B    同步浏览器URL 当用户使用 --- 改变地址栏、点击返回或前进按钮(或历史信息) 、点击链接

C   将URL 对象表示为一组方法(Protocol协议、Host主机、Port端口、Path路径、Search搜索、Hash散列)

Methods

absUrl();  --- This method is getter only

返回完整的URL 表示

<div ng-app="myApp" ng-controller="myCtrl">
	当前页面的URL : {{myUrl}}
</div>

<script>
	angular.module("myApp",[]).controller("myCtrl",function($scope,$location){
		$scope.myUrl=$location.absUrl();
	})
</script>
return:string 、full URL

protocol(); --- This method is getter only

返回当前URL 的协议

$location.protocol(); // http

host();  --- This method is getter only 

$location.host();  //www.xxx.com

port(); --- This method is getter only

$location.port(); //80,8080...
return --- number port

$timeout server

AngularJS 包装于window.setTimeout。fn 函数被包装到一个try / catch 块中并将任何异常委托于$exceptionHandler server




$rootElement

$rootElement 是AngularJS 应用的根元素。这是声明ngApp 或将元素传递给angular.bootstrap 的元素。元素表示应用程序的根元素。它也是应用程序$injector server 发布的位置,可以使用$rootElement.injector() 检索

JSON  (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It's easy for machines to parse and generate. It is based on subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值