AngularJS Server

来源:互联网 发布:淘宝 毛毯垫 编辑:程序博客网 时间:2024/05/16 15:36

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