absUrl( ):只讀;根據在 RFC 3986 中指定的規則,返回 url,帶有所有的片段。
hash( ):讀、寫;當帶有參數時,返回哈希碎片;當在帶有參數的情況下,改變哈希碎片時,返回$location。
host( ):只讀;返回 url 中的主機路徑。
path( ):讀、寫;當沒有任何參數時,返回當前 url 的路徑;當帶有參數時,改變路徑,并返回$location。(返回的路徑永遠會帶有/)
port( ):只讀;返回當前路徑的端口號。
PRotocol( ):只讀;返回當前 url 的協議。
replace( ):如果被調用,就會用改變后的 URL 直接替換瀏覽器中的歷史記錄,而不是在歷史記錄中新建一條信息,這樣可以阻止『后退』。
search( ):讀、寫;當不帶參數調用的時候,以對象形式返回當前 url 的搜索部分。
url( ):讀、寫;當不帶參數時,返回 url;當帶有參數時,返回$location。
Angularjs 中的 $anchorScroll服務 類似于錨點工具
angular.module('anchorScrollExample', []) .controller('ScrollController', ['$scope', '$location', '$anchorScroll', function($scope, $location, $anchorScroll) { $scope.gotoBottom = function() { // set the location.hash to the id of // the element you wish to scroll to. $location.hash('bottom'); // call $anchorScroll() $anchorScroll(); }; }]); //html 部分 <div id="scrollArea" ng-controller="ScrollController"> <a ng-click="gotoBottom()">Go to bottom</a> <a id="bottom"></a> You're at the bottom! </div>$cacheFactory主要是用在不同的controller 內 分享數據 不寫入瀏覽器緩存
用法 使用$cacheFactory服務
聲明使用服務
var cache = $cacheFactory('myCache'); cache.put('name','hello');//put就是寫入 。get是讀取 cache.put('age','20'); cache.put('job','it'); var name =cache('age')輸出 20?? //這是在同一controller 內使用如果在不同controller 內是用的話需要在使用cacheFactory的controller 注冊服務$cacheFactory
var cache = $cacheFactory.get('myCache'); //這樣就使用了共享數據controller 的數據了新聞熱點
疑難解答