码迷,mamicode.com
首页 > Web开发 > 详细

angular js 使用$location问题整理

时间:2015-07-02 17:42:13      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:angular js   location   

angular js 自带的$location方法十分强大,通过使用$location方法,我们可以获取到服务器的端口、杂乱连接中的path()部分(/所包含的部分);

例:

// given url http://example.com/#/some/path?foo=bar&baz=xoxo

var path = $location.path();

// => "/some/path"


但是在使用location之前,应该在文件的开头定义一下内容

/*

 * 定义angular js 调用$location方法 

 */

angular.module("hairApp",[],function($locationProvider){

    $locationProvider.html5Mode(true);

});

并且在controller中生命$location。

例:

angular.module(‘hairApp‘).controller(‘ProjectController‘, function($scope,$location,$http){})

版权声明:本文为博主原创文章,未经博主允许不得转载。

angular js 使用$location问题整理

标签:angular js   location   

原文地址:http://blog.csdn.net/huihuangjiuai/article/details/46726999

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