码迷,mamicode.com
首页 > 其他好文 > 详细

$location

时间:2014-08-26 13:33:16      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   os   io   ar   art   div   

大致上了解一下有什么功能操作,之后打算自己实现这个.

                    controller("ctrl", ["$scope", "$location", function ($scope, $location) {
                        //hash pattern 是 originUrl + "#/path?paraKey"
                        //$location 是同步当前url的,所以你set paraKey 等都会改变 url
                        //start url : http://localhost:5715/Angularjs/location/Default.aspx
                        var location_obj = $location.url("/path?x=y y"); //添加 hash, #/path?x=y 到url最后, 返回$location对象                       
                        //now url : http://localhost:5715/Angularjs/location/Default.aspx#/path?x=y%20y
                        var afterHash_str = $location.url(); //返回hash#后面的str : /path?x=y%20y (加密)   
                        var currentUrl = $location.absUrl(); //location.href. (加密)     
                        var http = $location.protocol(); //location.protocol
                        var host = $location.host(); //location.host
                        var port = $location.port(); //location.port
                        var path = $location.path(); //返回#之后的/path, without paraKey
                        var hash = $location.hash(); //不会  
                        var paraKeys = $location.search(); //返回paraKey对象,(解密)
                        $location.search({ x: "z z 1", y: "abc" }); //add and overwrite paraKey , cant clear
                        $location.search("y", null); //clear a paraKey
                    }]);

 

$location

标签:style   blog   http   color   os   io   ar   art   div   

原文地址:http://www.cnblogs.com/keatkeat/p/3937011.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!