首页 > 网站 > WEB开发 > 正文

$location

2024-04-27 14:19:51
字体:
来源:转载
供稿:网友

$location

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

                    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                    }]);


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表